Question: I have this problem in Java: Vehicles For this assignment you will create an inheritance chain with the Vehicle class as the super class. Write
I have this problem in Java:
Vehicles For this assignment you will create an inheritance chain with the Vehicle class as the super class. Write these three subclasses of Vehicle: Motorcycle Automobile Truck In addition to functioning as subclasses (to Vehicle), these they will also be super classes: Motorcycle will be a super class for the classes Sport Bike, and Cruiser. Automobile will be a super class for the classes Sport Car and SUV Truck will be a super class for PickUp and SemiTrailerTruck Each of the classes must include a toString method that identifies the class name for the object. For example, when calling the toString method from a class reference: instances of the PickUp class return the string PickUp instances of the Truck class return the string Truck Each of the classes must include a constructor that takes these arguments: top speed as an integer fuel source as an enum { GAS, DIESEL, ELECTRIC, HYBRID } number of wheels These three values must be stored in the Vehicle class, not in the subclasses. Include a separate class that functions as a test program. The main method should instantiate at least one of each of the seven classes and store the references in a polymorphic array (an array of type Vehicle). After loading the array, traverse it in a loop, and for each instance on its own line displays the return value from toString, top speed, fuel source, and number of wheels.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
