You need to supply a car class. I've fixed up the code and have gotten it to compile. But I've not tried in anyway to deal with getting this to work.
Remember to compile each time you add a small amount of code. I like to get a basic program working and add features incrementally rather than trying to get the whole program written at once. I hope this helps.
CODE
/** A CarDealer object represents a business that buys and resells used cars */
import java.util.ArrayList;
import java.util.HashMap;
public class CarDealer
{
private int dayNumber; // Day number from start of operation of business
// HashMap objects are used to provided easy lookup of cars using their registrations
// Each HashMap entry comprises a car registration as key, and the corresponding Car object
private HashMap<String, Car> prepStock; // To hold cars being prepared for sale
private HashMap<String, Car> saleStock; // To hold cars on sale
private int[] sales;
// An ArrayList field is needed, to hold the Sale objects created as sales are made
/** Constructor */
public CarDealer()
{
dayNumber = 1;
prepStock = new HashMap<String, Car>();
saleStock = new HashMap<String, Car>();
sales = new int[100];// to hold sales
}
public void advanceDate()
{
dayNumber++;
System.out.println("Day is now: " + dayNumber);
}
/** Note: Methods addCar, putOnSale, reducePrice and sellCar should print a confirmation
* message, or an error report if the operation cannot sensibly be performed.
*/
/** Method to be called when the dealer has acquired a car.
* A Car object representing the car is added to the preparation stock.
*/
public void addCar(String reg, String model, int paid)
{
System.out.println("addCar");
System.out.println("putOnSale");
System.out.println("reducePrice");
System.out.println("sellCar");
{
}
prepStock.put(reg, new Car(reg, model, paid));
}
/** Method to be called when a car is put on sale. The asking price must be specified.
* The Car object with the specified registration is moved to the sale stock.
*/
public void putOnSale(String reg, int ask)
{
Car c = saleStock.get(reg);
c.setAsk(c.getAsk());
}
/** Method to reduce the asking price of a car by a specified amount */
public void reducePrice(String reg, int amount)
{
Car c = saleStock.get(reg);
}
/** Method to be called when a car has been sold. The price received must be specified.
* The Car object with the specified registration is removed from the sale stock
* and an appropriate Sale object created and added to the collection of sales.
*/
public void sellCar(String reg, int received)
{
Car c = saleStock.get(reg);
reg = reg + received;
saleStock.remove(reg);
}
/** Method to print a report giving:
* - The number of cars sold so far
* - The total profit made on those sales
* - The average discount per sale.
*
* Notes:
* - The profit on a sale is the difference between the price obtained
* and the price the dealer paid for the car.
* - The discount on a sale is the difference between the asking price
* and the price obtained.
*/
public void printOverallSummary()
{
// Replace this comment with your code
}
/** Method to print a report giving:
* - The number of cars currently in preparation
* - The number of cars currently for sale
* - The number of cars sold on the current day
* - The total amount received for those sales
*/
public void printDaySummary()
{
System.out.println(prepStock.get("numCars"));
System.out.println(saleStock.get("numCars"));
if (dayNumber==dayNumber)
{
}
}
/** Method to print a report giving details of the single most profitable sale
* so far achieved.
*/
public void showBestSale()
{
}
/** Method to print a report giving details of every sale starting from a
* specified day and continuing up to another specified day.
*/
public void listDaySales(int dayFrom, int dayTo)
{
while(dayFrom < dayTo) {
}
}
/** Method to print a report giving details of all the sales achieved for a
* specified model.
*/
public void listModelSales(String reg, String model)
{
if(reg.equals(model))
System.out.println("sales");
//index++;
}
public class Car
{
double ask = 0.0;
public Car(String reg, String model, int paid)
{}
void setAsk(double d)
{
ask = d;
}
double getAsk()
{
return ask;
}
}
}