Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question Goal: Learn how to use Abstract Classes Assignment: Imagine that you are writing a program for a car dealership that will help them to
Question
Goal: Learn how to use Abstract Classes
Assignment: Imagine that you are writing a program for a car dealership that will help them to keep track of the different models they sell. Every car has the same basic properties such as make, model and year. But, each model has one extra unique characteristic.
The company recently got a new shipment of cars that it wants you to classify. The shipment includes three new types of cars: Sedans, Coupes, and SUVs. Sedans come with the option of a sunroof, Coupes come with the option of turbo, and SUVs come with the option of fourwheel drive.
A Car class has already been created for you. It implements a constructor method that stores the make, model, and year of production. Additionally, it implements a displayInfo method that prints out the car's attributes.
Write a new class for each of the new cars that extends the Car class. Each class should:
Implement it's own constructor which first invokes the constructor of the Car class and then stores the boolean value of its unique characteristic this should be determined by the user
Override the displayInfo method to display the make, model, and year followed by the value of the unique characteristic.
Example:
Enter a car type: SUV
Enter a make: Land Rover
Enter a model: Defender
Enter a year:
Fourwheel drive: true
Car Make: Land Rover
Car Model: Defender
Car Year:
FourWheel Drive: Yes
Parent class Car with basic attributes and methods
class Car
Common attributes for all cars
String make;
String model;
int year;
Constructor for Car class
public CarString make, String model, int year
this.make make;
this.model model;
this.year year;
A method that displays the car's information
public void displayInfo
System.out.printlnCar Make: make;
System.out.printlnCar Model: model;
System.out.printlnCar Year: year;
WRITE THE CODE HERE PLEASE, ALSO EXPLAIN SO THAT I MAY LEARN. THANK YOU!
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