Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package s3656260_A2;
- import java.util.*;
- public class RealEstateSystem {
- private static Scanner y = new Scanner(System.in);
- private static ArrayList<Sale> arrayL = new ArrayList<Sale>();
- public static void main(String args[]) {
- mainMenu();
- }
- public static void mainMenu() {
- System.out.printf("%-25s %s\n", "Add New Sale", "A");
- System.out.printf("%-25s %s\n", "Submit Offer", "B");
- System.out.printf("%-25s %s\n", "Display Sales Summary", "C");
- System.out.printf("%-25s %s\n", "Add New Auction", "D");
- System.out.printf("%-25s %s\n", "Close Auction", "E");
- System.out.printf("%-25s %s\n", "Exit Program", "X");
- String choose = y.next();
- switch (choose.toLowerCase()) {
- case "a":
- addNewSale();
- break;
- case "b":
- submitOffer();
- break;
- case "c":
- displaySales();
- break;
- case "d":
- addNewAuction();
- }
- }
- private static void addNewSale() {
- System.out.println("Enter Sale ID for new PropertySale:");
- String SaleIdInput = (y.next());
- System.out.println("Enter Property Adddress for new PropertySale:");
- String propertyAddressInput = (y.next());
- System.out.println("Enter Reserve Price for new PropertySale: ");
- int reservePriceInput = (y.nextInt());
- for (int x = 0; x < arrayL.size(); x++) {
- if (SaleIdInput.equals(arrayL.get(x).getsaleID())) {
- System.out.println("This SaleId already exists");
- mainMenu();
- }
- }
- Sale saleObject = new Sale(SaleIdInput, propertyAddressInput, reservePriceInput);
- arrayL.add(saleObject);
- System.out.print("New Property Sale added successfully for property at " + propertyAddressInput + '\n');
- mainMenu();
- }
- private static void submitOffer() {
- System.out.printf("%-25s %s", "Enter sale ID:", "");
- String SaleIdInput = (y.next());
- for (int x = 0; x < arrayL.size(); x++) {
- if (!SaleIdInput.equals(arrayL.get(x).getsaleID())) {
- System.out.println("This SaleId does not exist" + '\n');
- mainMenu();
- }
- System.out.printf("%-25s %s\n", "Current offer:", "0");
- System.out.printf("%-25s %s", "Enter new offer:", "");
- int offer = (y.nextInt());
- arrayL.get(x).makeOffer(offer);
- if (offer <= arrayL.get(x).getcurrentOffer()) {
- System.out.println("Error - New offer must be higher than current offer! Offer rejected!");
- }
- if (offer > arrayL.get(x).getreservePrice()) {
- System.out.print("Offer accepted! (this offer is above reserve price)" + '\n');
- }
- if (offer <= arrayL.get(x).getreservePrice()) {
- System.out.print("Offer accepted! (this offer is below reserve price)" + '\n');
- }
- }
- mainMenu();
- }
- private static void displaySales() {
- for (int x = 0; x < arrayL.size(); x++) {
- System.out.println(arrayL.get(x).getSalesDetails());
- }
- mainMenu();
- }
- private static void addNewAuction() {
- System.out.println("Enter Sale ID for new Auction Sale:");
- String auctionSaleIdInput = (y.next());
- System.out.println("Enter Property Address for new Auction Sale:");
- String auctionPropertyInput = (y.next());
- System.out.println("Enter Reserve Price for new Auction Sale: ");
- int auctionReservePriceInput = (y.nextInt());
- for (int x = 0; x < arrayL.size(); x++) {
- if (auctionSaleIdInput.equals(arrayL.get(x).getsaleID())) {
- System.out.println("SaleId: " + auctionSaleIdInput + " already exist");
- mainMenu();
- }
- }
- Sale saleObject = new Sale(auctionSaleIdInput, auctionPropertyInput, auctionReservePriceInput);
- arrayL.add(saleObject);
- System.out.print("New Property Sale added successfully for property at " + auctionPropertyInput + '\n');
- mainMenu();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement