Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hide Assignment Information Instructions Attached is the Java class Vehicle.java. Download this file and create two new Java classes that inherit (extend) from Vehicle.java One
Hide Assignment Information Instructions Attached is the Java class Vehicle.java. Download this file and create two new Java classes that inherit (extend) from Vehicle.java One class should represent a Car. Car class should have additional attributes of numberOfDoors and color. Create appropriate constructors (all args) and setter/getter methods. Create a toString method that also prints the attributes from the parent class. One class should represent a Truck. Truck class should have additional attributes of numberOfDoors and cargoCapacity (sq feet). Create appropriate constructors (all args) and setter/getter methods. Create a toString method that also prints the attributes from the parent class. Create a main method in a fourth class. Create instances of Truck and Car. Populate them with appropriate attributes and print the results. You do not have to get attribute values from the user. Due Date Jan 31. 2020 11:30 PM Submit Cancel 1371 of 320M MacBook P. Vehicle.java "Car.java Truck.java public class Vehicle 1 // common attributes of motor vehicles private double horsepower; private int numberOfWheels; 60 ** * @param horsepower * @param numberOfWheels public Vehicle(double horsepower, int number ofWheels) 200 this.horsepower = horsepower; this.numberOfWheels = number of Wheels; 260 27 @Override public String toString() return "Vehicle (horsepower" 29 30 horsepower + ", number of wheel numberofwheels 320 350 *** * @return the horsepower public double getHorsepower() return horsepower; * @param horsepower the horsepower to set protected void setHorsepower(double horsepower) this.horsepower = horsepower; * @return the numberOfWheels public int getNumberOfWheels() return numberOfwheels: * @paran numberOfWheels the numberOfWheels to set protected void setNumberOfWheels(int numberorWheels) this number of Wheels - number ofWheels; 180M 320M Wiritable MacBook Pro
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started