Assignment 03
Assignment 03
Fundamentals
Assignment 03 Page 1 of 3
CC-211 Object Oriented Programming FALL 2022
Fundamentals
Objectives:
This assignment will provide experience with concepts of Inheritance and Polymorphism
Prerequisite Skills:
Basic knowledge of mathematical calculations
Understanding of Class design
Understanding of Inheritance
Understanding of Polymorphism
Overview:
Polymorphism is the third pillar of object-oriented programming (OOP) after encapsulation and
inheritance. Polymorphism allows an interface to be expressed in different ways. Real-world
examples are commonplace; for example, the taxonomy used in biology to classify organisms is
polymorphic.
In this assignment, you will create a program that models a vehicle inventory using polymorphism.
The inventory will contain several types of vehicles such as cars, trucks, and motorcycles, each of
which will have different properties and methods.
Problem Statement:
Instructions:
Create a base class called “Vehicle” that has the following data members:
o make (string), model (string), year (integer), price (double)
The class should also have a virtual method called “displayInfo” that takes no parameters and
returns nothing.
Create three derived classes: “Car”, “Truck”, and “Motorcycle” that inherit from the “Vehicle”
base class.
o The “Car” class should have an additional data member called “numDoors” (integer).
o The “Truck” class should have an additional data member called “bedSize” (string).
o The “Motorcycle” class should have an additional attribute called “engineSize” (double).
All derived classes should override the “displayInfo” to display its specific vehicle information.
The “Car” class should output the make, model, year, price, and number of doors.
The “Truck” class should output the make, model, year, price, and bed size.
The “Motorcycle” class should output the make, model, year, price, and engine size.
Create a main program that creates several instances of each vehicle type, sets their properties,
and calls their “displayInfo” method to display them. Use a polymorphic approach to call the
“displayInfo” method of each vehicle object. The output of the program should be a visual
display of all the vehicles in the inventory.
Specifications:
Implement the following features to enhance the program:
Implement a way to add new vehicles to the inventory.
Implement a way to remove vehicles from the inventory.
Implement a way to search for a specific vehicle by make, model, year, or price.
Implement a way to sort the vehicles by make, model, year, or price.
File(s) to be submitted:
VehicleInventory.cpp, VehicleInventory.h, should be submitted to Teacher Assistant in the electronic
format i.e., softcopy.