Question
Question 1 Problem Statement: We have a showroom known as BILAL MOTORS PVT LTD. Due to the COVID-19 pandemic, we want to launch an online
Question 1
Problem Statement:
We have a showroom known as BILAL MOTORS PVT LTD. Due to the COVID-19 pandemic, we want to launch an online system BILAL MOTORS DATABASE for our showroom,so that information of the different vehiclescan be storedand people can check the information and availability of the vehicles sitting in their home by using online system.This will allow reducing the movement of people and minimizing the spread ofthedisease. The proposed systemwill offer information and availability of differentvehicleslike Bike, Car and Truck.Now you have todesign a set of classes for storing Vehicleinformation, along witha class that will manage databaseof vehicles. Data shouldalsobe exported to file for storage of the information of the available vehicles at out showroom
.1.Design a set of classes that can store vehiclesinformation. There should be one base class named as Vehicleto store common data, and three derived classes that dividesthe set of vehicleinto three categories: Bike, Car, and Truck. All datastored in these classes should be private. Any access to class data from outside should be done through public member functionsknownas setters and getters. The Vehicleclass should allocate storage for the followingdata.
Attributes:
companyName:(character pointer)
color:(character pointer)
numberOfWheels:(int)
powerCC: (int)
typeOfVehicle:(char pointer)eg: bike, car, truck
Methods:
virtual voidcheckType()=0;
This function should be responsible to determine the type of vehicle, but you are not allowed to define it in this Class.For eg: if it has two wheelsthen it is bike.
virtual void display()const;This function display() will only print the attributes.Remember:Your Programme should not allow to make an objectof Base Class Vehicle.
2.Each derived class should have a function checkType()that will check the type of vehicleand setthe Vehicles's typeOfVehcilebased on the stored information about number of wheels (attribute). All typesare based on number of wheels.
Bike:
Attributes:
height:(double)
selfStart:(bool)
discBrake: (bool)
numberOfBikes : static int //This is to store the number of available bikes
Car
Attributes:
noOfDoors:(int)
trasmission:(character pointer) eg: automatic or manual
noOfSeats: (int)
numberOfCars : static int //This is to store the number of available cars
Truck:
Attributes:
containerSize:(double)
category:(character pointer) eg: double-cabin or single-cabin
fourWheelDrive : (bool)
numberOfTrucks : static int//This is to store the number of available trucks
What else is required:
For each class aboveprovide:
oParameterized constructor with default argumentsand Copy Constructor(use base initializer list with both constructors)oDestructor(with no memory leakage)
oGetters/Setters for all private attributes(with no memory leakage and no returning of original memory handler)
oAssignment Operator(with no memory leakage)
oDont provide function where you can overload operators, therefore must provide the following operators(only in child classes):cin>> and cout
3.Write a class called BilalMotors, which will be used to store the list of various vehicles, using a single arrayof pointersof flexible size.
Note:Each item in the array should be a Vehiclepointer, which should point to the appropriate type of Vehicle. Your list should only be big enough to store the vehiclesflexibly.Note that the BilalMotorsclass is NOTpart of the inheritance hierarchy described in the first two items above. This class is used to store and manage a LIST of individual vehicles.
So all these vehiclesare held by a list class named asBilalMotors.
BilalMotors:
Attributes:
Arrayof pointersto hold all the vehicles
A counter to maintain number of Vehiclesadded and indexing of the array
Methods:
Your BilalMotorsclass needs to have these public functions available:
BilalMotors( )
Default constructor:Sets up an empty list.
addVehicle(Vehicle*)
It will add a newvehicleinto the array.
searchVehicle(char*)
Function to find all the availablevehiclesby typee.g. Bikewill find and display all such vehicleswith type Bike.
~ BilalMotors( )
Destructor:
Needs to reset all the array pointers with nullptr.
bool saveData(const char* fileName)const;
This function should create a fileand writethe number of all the vehicles available andall the data of the vehicles into an output file (filename shouldbe passed by the user in the function). For example if user passes Bilal Ishfaq Motors. Your function should open file Bilal Ishfaq Motors.txt and write all data required in it.
File format is described below: Vehicle Information Number of Bikes: 2 Number of Cars: 2 Number of Trucks: 2 Company Name Type Color Power Suzuki Road Prince Suzuki Honda Toyota Isuzu Bike Bike Car Car Truck Truck Red Black White Black Red Black 150 70 800 1349 2799 2499 If the output file cannot be opened, return false for failure. Otherwise, after writing into file, return true for success. Remember: You are not allowed to retum the memory handler (no getter) of the array outside the class. Hint: Overload indexing/subscript [operator (both const and non-const) for it./ Driver Programme/main(): A Non-Member Function: Function that display whole information of all the vehicles on the screen. Hint: Will require indexing/subscript[] operator. void ShowVehicles(const BilalMotors &); You cannot call any getters in this above function, except getCount(). This function should print the number of total vehicles available to the screen and the current list of vehicles, one vehicle per line. All the information needs to be printed in this printout including inherited information and its own information. Output format should be: Number of Total Vehicles: 2 Company Color Wheels Power Type Doors Transmission Seats Suzuki White 800 Car 4 automatic 5 Company Color Wheels Power Type Height SelfStart DiscBrake Honda Red 2 70 Bike 22.2 NO NO 4. Write a main program (in a separate file) that creates a single Bilal Motors object and then implements a menu interface to allow interaction with the object. Your main program should implement the following menu loop (any single letter options should work): *** BILAL MOTORS - * S E 2. Show vehicles list brief) Create a data file (output file) Add new vehicle B for Bike C for Car T for Truck Find Vehicle by type Quit Program E Q The Create a data file option should call the appropriate class function for printing the available vehicles information to file, respectively. The Show vehicles list option should call the non-member function that prints the whole information of all available vehicles to screen. The Find Vehicle option should find all the vehicles of the given type and display its information. Quit should end the menu program. (Until this option is selected, keep looping back for menu selections). General Requirements: No global variables! All member data of your classes must be private Use the const qualifier on member functions wherever it is appropriate. The code for this program should be portable. Test on compiler on sufficient test cases before submitting File format is described below: Vehicle Information Number of Bikes: 2 Number of Cars: 2 Number of Trucks: 2 Company Name Type Color Power Suzuki Road Prince Suzuki Honda Toyota Isuzu Bike Bike Car Car Truck Truck Red Black White Black Red Black 150 70 800 1349 2799 2499 If the output file cannot be opened, return false for failure. Otherwise, after writing into file, return true for success. Remember: You are not allowed to retum the memory handler (no getter) of the array outside the class. Hint: Overload indexing/subscript [operator (both const and non-const) for it./ Driver Programme/main(): A Non-Member Function: Function that display whole information of all the vehicles on the screen. Hint: Will require indexing/subscript[] operator. void ShowVehicles(const BilalMotors &); You cannot call any getters in this above function, except getCount(). This function should print the number of total vehicles available to the screen and the current list of vehicles, one vehicle per line. All the information needs to be printed in this printout including inherited information and its own information. Output format should be: Number of Total Vehicles: 2 Company Color Wheels Power Type Doors Transmission Seats Suzuki White 800 Car 4 automatic 5 Company Color Wheels Power Type Height SelfStart DiscBrake Honda Red 2 70 Bike 22.2 NO NO 4. Write a main program (in a separate file) that creates a single Bilal Motors object and then implements a menu interface to allow interaction with the object. Your main program should implement the following menu loop (any single letter options should work): *** BILAL MOTORS - * S E 2. Show vehicles list brief) Create a data file (output file) Add new vehicle B for Bike C for Car T for Truck Find Vehicle by type Quit Program E Q The Create a data file option should call the appropriate class function for printing the available vehicles information to file, respectively. The Show vehicles list option should call the non-member function that prints the whole information of all available vehicles to screen. The Find Vehicle option should find all the vehicles of the given type and display its information. Quit should end the menu program. (Until this option is selected, keep looping back for menu selections). General Requirements: No global variables! All member data of your classes must be private Use the const qualifier on member functions wherever it is appropriate. The code for this program should be portable. Test on compiler on sufficient test cases before submittingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started