This is a multi-part problem in which you will construct several object classes and a short demonstration
program1
. Submit the completed program (all 4 parts) including all class definitions/implementations in a
single .cpp source file (i.e., do not construct separate files for class headers and implementation).
A used car dealership maintains an inventory of several types and models of vehicles. There are three kinds of
vehicles: Cars, Trucks and SUVs. Regardless the type, the dealership maintains the following information for
every vehicle:
• Make : string
• Model : string
• Year : integer
• Mileage : integer
Additional information is maintained for each individual vehicle depending on its type:
For Cars: Number of doors (2 or 4)
For Trucks: Drive type (2-wheel drive or 4-wheel drive)
For SUVs: Passenger Capacity
Part 1
Construct a base class named Vehicle to maintain the common vehicle data. The class should include a
constructor that will support initializing all 4 attributes as well as separate accessor and mutator methods for
each data attribute.
Part 2
Construct three additional classes named Car, Truck and SUV to represent Cars, Trucks, and SUVs
respectively. Each of these classes should be derived from the Vehicle class and extended by adding the
attributes unique to the type of vehicle. Each class should provide a constructor to initialize its attribute(s) as
well as the attributes of the parent class. Provide accessor and mutator methods for each class to get and set the
attributes for the particular class.
Add a method named Display to each of the four classes to print out the individual vehicle information. For
the Vehicle class, the Display method should print the following (one element per line):
Make: vehicle_make
Year: vehicle_year
Model: vehicle_model
Miles: vehicle_mileage
Each vehicle-type class (Car, Truck, SUV) should print out the information specific to its own type in addition
to the vehicle information. Note that you can print the vehicle information using a call to the base class
Display method: Vehicle::Display(). Here is an example of the output for a Car:
Inventory unit: Car
Make: Audi
Year: 2009
Model: A8
Miles: 40000
Number of doors: 4
Part 4
Finally, write a main program to test your classes. Instantiate 5 objects to represent the following vehicles:
car: 1987 Audi A6 4-door with 185,000 miles
car: 1963 Volkswagen Beetle 2-door with 240,000 miles
truck: 2007 Ford 4-wheel drive F-150 with 82,000 miles
suv: 2001 8-passenger Chevrolet Suburban with 118,000 miles
suv: 2010 5-passenger Kia Sorento with 29,000 miles
Print out the vehicle information for all 5 vehicles using the .Display() method for each vehicle.