Question: Help with Java! Write a Car class that includes attributes of cars. It must include either price or value (it can include both). Be sure

Help with Java!

Write a Car class that includes attributes of cars. It must include either price or value (it can include both). Be sure to determine the getters and setters that need to be written, and write the toString() Method appropriately so when you print a car, it make sense.

The class with the main method will contain a garage (ArrayList) that contains several cars. The user must be able to add a car to the garage, print the contents of the garage, get the value of the cars in the garage, remove a car from the garage (like selling it).

This is what I have so far and it's not right. Can anyone help me fix this code?

Public class Car

{

Private String make;

Private String model;

Private int price;

public Car (String make, String model, int year)

}

public String setCarMake (String make)

{

this.make = make;

return make;

}

public String getCarMake ()

{

return make;

}

public String setCarModel (String model)

{

this.model = model;

return model;

}

public int getCarPrice ()

{

return price;

}

public String toString()

{

return Car make: + make +

Car model: + model + Car Price: + price;

}

public static void main (String[] args)

{

Car car1 = new Car (Jeep, Cherokee, 30,000);

Car car2 = new Car (Nissan, Rouge, 45,000);

Car car3 = new Car (Lincoln, Navigator, 65,000);

car1.setCarMake (Jeep);

System.out.printls (car1);

System.out.println (car1.getCarPrice());

Car2.setCarModel (Rouge);

System.out.println (car2);

System.out.println (car2.getCarMake());

Car3.setCarPrice(30,000);

System.out.println (car3);

System.out.println (car3.getCarModel());

}

}

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!