Question: Java help, ASAP ! Can someone please tell me what I am doing wrong? My code does not want to run Lot.java class Lot {

Java help, ASAP! Can someone please tell me what I am doing wrong? My code does not want to run

Lot.java

class Lot { private static int nextLotNumber = 1001; private int lotNumber; private String description; private int currentBid; private int bidIncrement; private boolean sold; public Lot() { lotNumber = nextLotNumber++; description = "Unknown Item"; currentBid = 0; bidIncrement = 0; sold = false; } public Lot(String description, int startingBid, int bidIncrement) { lotNumber = nextLotNumber++; this.description = description; currentBid = startingBid; this.bidIncrement = bidIncrement; sold = false; } public void markSold() { sold = true; } public boolean isSold() { return sold; } public int getBidIncrement() { return bidIncrement; } public String getDescription() { return description; } public void setCurrentBid(int currentBid) { this.currentBid = currentBid; } public int nextBid() { return currentBid + bidIncrement; } @Override public String toString() { if (sold) { return "Lot " + lotNumber + ". " + description + " was sold for $" + currentBid; } else { return "Lot " + lotNumber + ". " + description + " current bid $" + currentBid + " minimum bid $" + nextBid(); } } }

Auction.java

import java.util.ArrayList; import java.util.Scanner; class Auction { private static ArrayList lots = new ArrayList(); private static Scanner scanner = new Scanner(System.in); public static Lot getNextLot(ArrayList lots) { if (lots.size() > 0) { Lot nextLot = lots.get(0); lots.remove(0); return nextLot; } else { return new Lot(); } } public static void addItem(ArrayList lots) { System.out.print("What is the description of this item?"); String description = scanner.nextLine(); System.out.print("What is the starting bid?"); int startingBid = scanner.nextInt(); System.out.print("What is the bid increment?"); int bidIncrement = scanner.nextInt(); scanner.nextLine(); lots.add(new Lot(description, startingBid, bidIncrement)); } public static void bid(Lot lot) { System.out.print("Enter bid: "); int bid = scanner.nextInt(); scanner.nextLine(); if (bid >= lot.nextBid()) { lot.setCurrentBid(bid); } else { System.out.println("Bid must be at least $" + lot.nextBid()); } } public static void markSold(Lot lot) { } public static void mainMenu(ArrayList lots) { Lot currentLot = null; int userChoice = 0; while (userChoice != 5) { System.out.print("Current Lot: "); if (currentLot == null || currentLot.getDescription().equals("Unknown Item") || currentLot.isSold()) { System.out.println("We are not currently bidding"); } else { System.out.println(currentLot.getDescription()); } System.out.println("1. Add Lot to Auction"); System.out.println("2. Start bidding on next Lot"); System.out.println("3. Bid on current Lot"); System.out.println("4. Mark current Lot sold"); System.out.println("5. Quit"); System.out.print("Enter your choice: "); userChoice = scanner.nextInt(); switch (userChoice) { case 1: if (scanner.equals(1)) { addItem(lots); } //addot(lots); break; case 2: if (lots.size() == 0) { System.out.println("There is nothing to bid on, add an item first"); } else { currentLot = getNextLot(lots); } break; case 3: if (currentLot == null || currentLot.getDescription().equals("Unknown Item") || currentLot.isSold()) { System.out.println("You must first bring a Lot up for bidding"); } else { bid(currentLot); } break; case 4: if (currentLot == null || currentLot.getDescription().equals("Unknown Item") || currentLot.isSold()) { System.out.println("You must first bring a Lot up for bidding"); } else { markSold(currentLot); } break; case 5: System.out.println("Goodbye!"); break; default: System.out.println("Invalid choice, try again"); break; } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!