Question: Java Program The Dealer class and the Car class (Filename: TestDealerCar.java) a. Design and implement a class named Car. A car has a serial number,
Java Program The Dealer class and the Car class (Filename: TestDealerCar.java)
a. Design and implement a class named Car. A car has a serial number, a make (such as Toyota), a model (such as Camry), a year built, and a price. The serial number of a new car is automatically created. It is one more than the last serial number used by the dealer. Create appropriate constructor(s) and accessor and mutator methods for the Car class.
b. Design and implement a class named CarDealer. A CarDealer has a name, the actual number of cars, and a list of cars (which is an array of Car objects. Assume that the maximum number of cars in a car dealer is 1000), and the actual number of cars. Create a constructor for creating a CarDealer object with a given name. Create a method for adding a car to a car dealer and another method for returning the array of all cars. Add another method to get the number of cars in a car dealer.
c. In the main method, create a new CarDealer object and create two cars. Add the two cars to the car dealer object. Get the list of cars from the CarDealer object and display their serial numbers, makes, types, years built, and prices.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
