Question: Create a Java program that will contain the following architecture: 1) Create an abstract class called Auto in Auto.java that contains the following data and

Create a Java program that will contain the following architecture: 1) Create an abstract class called Auto in Auto.java that contains the following data and methods: a) Private Class Data i) string brandName ii) float milesPerGallon iii) string color b) Public Class Methods i) Auto(string name, float mpg, string color) ii) string getBrandName() iii) void setBrandName(string name) iv) float getMilesPerGallon() v) void setMilesPerGallon(float mpg) vi) string getColor() vii) void setColor(string color) viii) abstract string printStats() 2) Create a specialization class called Truck in Truck.java that extends the Auto class and contains the following data and methods: a) Private Class Data i) int horsePower b) Public Class Methods i) Truck(string name, float mpg, string color, int horsepower) ii) string printStats() will return the information about the truck in string form. For example, Truck Brand: GMC MPG: 5.0 Color: Silver HP: 600 3) Create a specialization class called Car in Car.java that extends the Auto class and contains the following data and methods: a) Private Class Data ii) integer numberOfDoors b) Public Class Methods i) Car(string name, float mpg, string color, int numDoors) ii) string printStats() will return the information about the car in string form. For example, Car Brand: Porsche MPG: 10.0 Color: Red Number of Doors: 4 Then create a test class called AutoTest in AutoTest.java that contains the following code in main(): ArrayList autoList = new ArrayList; Car newCar = new Car(Corvette, 8.0, Red, 2); Truck newTruck = new Truck(Toyota, 10.0, Silver, 500); autoList.add(newCar); autoList.add(newTruck); for (Auto a : autoList) a.printStats(); When you run the test application, the output should be as follows: Car Brand: Corvette MPG:8.0 Color:Red Number of Doors:2 Truck Brand: Toyota MPG:10.0 Color:Silver HP:500

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!