Question
Please follow the following statements: (UPLOAD Vehicle.java & Car.java & Bicycle.java & VehicleTest.java) a. Create an abstract class Vehicle including only one abstract method which
Please follow the following statements: (UPLOAD Vehicle.java & Car.java & Bicycle.java & VehicleTest.java)
a. Create an abstract class Vehicle including only one abstract method which is GetCarbonFootprint.
b. Create a subclass Car. A car has an instance variable gallon and a constructor. A cars carbon footprint is calculated by gallons *20.
c. Create another subclass Bicycle. A bicycles carbon footprint is 0.
d. Create a test class. Include a Vehicle array with a length of 2. The first element of it will be a car and the second element of it will be a bicycle.
e. Display carbon footprints of the car and bicycle by calling the method GetCarbonFootprint polyphormically.
Sample Output:
:\Java\assignments4306java VehicleTest Bicycle: 0 c Car that has used 40,00 gallons of gas: 800,00
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