Answered step by step
Verified Expert Solution
Link Copied!

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions