Question: 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 four-wheel 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: 2002
Four-wheel drive: true
Car Make: Land Rover
Car Model: Defender
Car Year: 2002
Four-Wheel 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 Car(String 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.println("Car Make: "+ make);
System.out.println("Car Model: "+ model);
System.out.println("Car 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!