Question: CSCI - 2 4 6 7 Lab 7 Inheritance Assignment Download the Lab 0 7 . zip starter file. Use 7 zip to unzip the
CSCI Lab Inheritance Assignment
Download the Labzip starter file. Use zip to unzip the file using Extract Here Open the project folder in IntelliJ.
Examine the Main and Car classes. You are going to add two classes derived from Car: GasolineCar and ElectricCar.
Create GasolineCar class
Select package edu.cscc and create a new Java class called GasolineCar Make the class inherit from the Car class
Add two private field in the following order:
An int field named cylinders which denotes the numbers of cylinders in the car's gasoline engine
A double field named tankCapacity which lists the car's gas tank capacity in gallons
Generate a constructor and all getters and setters
Add a describe method that overrides the method in the base class. It should call the base class describe method
and then print the car's number of cylinders and gas tank capacity see Example Output below
In the Main class uncomment the gasoline cars in the carFleet array see TODO comment and run the program to test your new code. Verify the output and fix any bugs in your GasolineCar class that you detect.
Create ElectricCar class
Select package edu.cscc and create a new Java class called ElectricCar
Make the class inherit from the Car class
Add a private int field batterySize which lists the car's battery capacity in kilowatt hours
Generate a constructor and all getters and setters
Add a describe method that overrides the method in the base class. It should call the base class describe method
and then print the car's battery capacity see Example Output below
In the Main class uncomment the electric cars in the carFleet array see TODO comment and run the program to test your new code. Verify the output and fix any bugs in your ElectricCar class that you detect.
Finally, find the initial TODO comment in the Main class replace the comment with a comment including your name, the date, and the purpose of the program.
Turning in Your Assignment
Once youve completed and thoroughly tested your assignment, you are ready to submit it Zip your IntelliJ project folder for this lab and upload the zip file to Blackboard for grading.
Students who submit projects that do not compile will receive a zero for the lab.
Example Output
Our Car Fleet Vehicle # Make: Toyota
Model: Rav
Year:
Cylinders:
Fuel Tank Capacity: Vehicle #
Make: Ford
Model: F
Year:
Cylinders:
Fuel Tank Capacity: Vehicle #
Make: Honda
Model: Civic
Year:
Cylinders:
Fuel Tank Capacity: Vehicle #
Make: Tesla
Model: Model
Year:
Battery size:
Vehicle #
Make: Tesla
Model: Model Y
Year:
Battery size:
Vehicle #
Make: Aston Martin Model: Rapide E
Year:
Battery size:
Process finished with exit code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
