uppose we are developing a program that a car dealership can use to manage its inventory of used cars. The dealership’s inventory includes three types of automobiles: cars, pickup trucks, and sport-utility vehicles (SUVs). Regardless of the type, the dealership keeps the following data about each automobile: Make Year model Mileage Price Each type of vehicle that is kept in inventory has these general characteristics, plus its own specialized characteristics. For cars, the dealership keeps the following additional data: Number of doors (2 or 4) For pickup trucks, the dealership keeps the following additional data: Drive type (two-wheel drive or four-wheel drive) And, for SUVs, the dealership keeps the following additional data: Passenger capacity In designing this program, one approach would be to write the following three classes: A Car class with attributes for the make, year model, mileage, price, and number of doors. A Truck class with attributes for the make, year model, mileage, price, and drive type. An SUV class with attributes for the make, year model, mileage, price, and passenger capacity. This would be an inefficient approach, however, because all three classes have a large number of common data attributes. As a result, the classes would contain a lot of duplicated code. In addition, if we discover later that we need to add more common attributes, we would have to modify all three classes. A better approach would be to write an Automobile base/Parent class to hold all the general data about an automobile, and then write derived classes (Car, PickUpTruck, SUV which extends the Parent Class automobile) for each specific type of automobile. Create an Automobile class with above attributes, Provide getter, setters, constructors and toString method. Write a class Car which extends Automobile class with attribute noOfDoors, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method. Write a class PickUpTruck which extends Automobile class with attribute driveType, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method. Write a class SUV which extends Automobile class with attribute passengerCapacity, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method. Now in the main you have to create objects of three types of automobiles

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Suppose we are developing a program that a car dealership can use to manage its inventory of used cars. The dealership’s inventory includes three types of automobiles: cars, pickup trucks, and sport-utility vehicles (SUVs).

Regardless of the type, the dealership keeps the following data about each automobile:

  • Make
  • Year model
  • Mileage
  • Price

Each type of vehicle that is kept in inventory has these general characteristics, plus its own specialized characteristics. For cars, the dealership keeps the following additional data:

  • Number of doors (2 or 4)

For pickup trucks, the dealership keeps the following additional data:

  • Drive type (two-wheel drive or four-wheel drive)

And, for SUVs, the dealership keeps the following additional data:

  • Passenger capacity

In designing this program, one approach would be to write the following three classes:

  • A Car class with attributes for the make, year model, mileage, price, and number of doors.
  • A Truck class with attributes for the make, year model, mileage, price, and drive type.
  • An SUV class with attributes for the make, year model, mileage, price, and passenger capacity.

This would be an inefficient approach, however, because all three classes have a large number of common data attributes. As a result, the classes would contain a lot of duplicated code. In addition, if we discover later that we need to add more common attributes, we would have to modify all three classes.

A better approach would be to write an Automobile base/Parent class to hold all the general data about an automobile, and then write derived classes (Car, PickUpTruck, SUV which extends the Parent Class automobile) for each specific type of automobile.

Create an Automobile class with above attributes, Provide getter, setters, constructors and toString method.

Write a class Car which extends Automobile class with attribute noOfDoors, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method.

Write a class PickUpTruck which extends Automobile class with attribute driveType, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method.

Write a class SUV which extends Automobile class with attribute passengerCapacity, provide default and parameterized constructor (with super keyword set values of parent’s attributes), getters, setters, and toString method.

Now in the main you have to create objects of three types of automobiles using parametrized constructor and print their values.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY