Question: code using java 1. Implement Vehicie class with all its data fields and methods and override the toString() method to display the manufacturer name, model


1. Implement Vehicie class with all its data fields and methods and override the toString() method to display the manufacturer name, model and year as below example: 10 pts Manufacture = Nissan, model = Sunny, year =2022 2. Implement the Dealer class with all its data fields and methods. 10pts 3. Implement the Truck class with all its data fields and methods a. Override calculatePricel) method to return the price of the truck (using the getPrice() method). 5pts b. Override the toString() method to return "Truck," + the number of wheels + the price (using calculatePrice()) and concatenate it with the tostringl method from the superclass as shown in the below example: 5 pts Truck, Number of Wheels =6, Price 150000.0 Manufacturern Volvo, model v vx2, year =2020 5. Implement the Car class with all its data fields and methods. Note that the class implements 2 interfaces, Comparable and Convertible. 5pts a. Override the isConvertible() method 5pts b. Override the calculatePrice() method to add 10% to the original price if the car is convertible. (You must use getPricel) and isConvertable() methods) 5 pts c. Override the toString() method to return "Car, " + type + convertible + price (using calculatePrice()), and concatenate it with the tostring() method from the superclass as shown in the below example: 5pts Car, type= Sedan, convertiblew false, Price 20000.0 Manufacturera Nissan, model= Sunny, yeara 2022 d. Override the compareTol) method, from interface Comparable, to compare the prices of 2 car objects. 10pts Part 2: [30 points] - The driver class 1. Create a dealer object. 5pts 2. Create 1 truck and 2 car objects 5pts 3. Add the created objects to the ArrayList (already declared in the Dealer class) 5pts 4. Display the info of all the objects found in the ArrayList. (Check the sample run below) 5 pts 5. Display the info of all the cars objects found in the ArrayList 5pts 6. Compare the 2 car objects already created and display the one which has the heights price (using the compareTo() method already created) 5pts Your program should execute exactly as the below sample run: All Vehicles info: Truck, Number of Wheels= 6, Price =150000.0 Manufacturer = Volvo, model= vx2, year= 2020 Car, type= Sedan, convertible= false, Price =20000.0 Manufacturer= Nissan, model= Sunny, year= 2022 Car, type= HatchBack, convertible= true, Price= 16500. 0 Manufacturer= Toyota, model= Yaris, year= 2019 Cars info: Car, type = Sedan, convertible = false, Price =20000.0 Manufacture = Nissan, model= Sunny, year =2022 Car, type= HatchBack, convertible= true, Price =16500.0 Manufacturer= Toyota, model = Yaris, year= 2019 The car having the highest price is: Car, type = Sedan, convertible = false, Price =20000.0 Manufacturer = Nissan, model = Sunny, year =2022
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
