Question: JAVA I need help, my code doesn't want to run. I have them in 2 files, the first is Lot.java and the second is Auction.java

JAVA

I need help, my code doesn't want to run.

I have them in 2 files, the first is Lot.java and the second is Auction.java

I also tried changing Lot.java to Main.java and it didn't work.

Main.java

import java.util.ArrayList; import java.util.Scanner; 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

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("Enter description: "); String description = scanner.nextLine(); System.out.print("Enter starting bid: "); int startingBid = scanner.nextInt(); System.out.print("Enter 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) { } 

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!