This project will expand by adding additional functionality, and implementing more abstract data types (ADTs) and their operations through classes. Pointers must be used for array manipulation, including arrays with ADTs (structs, classes) e.g, rental cars, rental agencies. Pointers must be used in function prototypes and function parameter lists - not square brackets. Const should be used in parameter lists, functions, and function signatures as appropriate. Any of your work (functions/ADTs/etc) produced up to Project_3 (such as your changed pointer-based string functions, e.g. string copy) have to be modified to use const (e.g. for string copy const-pointers) where appropriate. Square brackets should be used only when declaring an array, or if otherwise specified in the context of an overloaded ([]) operator. Pointers can only be moved by incrementing or decrementing (i.e., ++ or - -), or by setting the pointer back to the base address using the array name. You should now use the arrow operator (-) with any pointers where appropriate.
The additional functionality is as follows: You are given an updated data file where there is 1 rental car agency location (RentalAgency) which has 5 cars (RentalCar). Each car can also incorporate up to 3 (0-3) special driving sensors (CarSensor). You will have the same menu options, but the functionality has been updated below. Note: using multiple helper functions to do smaller tasks will make this project significantly easier.
The CarSensor Class will contain the following private data members:
type, a C-style string (name of sensor type), valid strings for CarSensor m_type are "gps", "camera", "lidar", "radar", "none".
extracost, a float (additional rent cost per day for the car that carries the sensor, for "gps":=$5.0/day, for "camera":=$10.0/day, for "lidar":=$15.0/day, for "radar":=$20.0/day, for "none":=$0.0/day)
gps_cnt, a static int member (keeps track of existing gps-type sensors)
camera_cnt, a static int member (keeps track of existing camera-type sensors)
lidar_cnt, a static int member (keeps track of existing lidar-type sensors)
radar_cnt, a static int member (keeps track of existing radar-type sensors)
and will have the following methods:
Default Constructor - will set the aforementioned data members to default initial values.
Parameterized Constructor - will create a new object based on the values passed into it.
Copy Constructor - will create a new object which duplicates an input CarSensor object.
Get/Set methods for appropriate data member(s).
A Get and a Reset member function to return and to reset each of the static member variables.
A Method to check if 2 CarSensor objects are the same. You should try to make this an operator overload of (operator==).
The RentalCar Class will contain the following private data members:
make, a C-style string (car make)
model, a C-style string (car model)
year, a (preferably const) int (year of production)
tank, a (preferably const) float (max tank capacity in gallons)
sensors, a CarSensor class type array of size 3 (max allowable number). (You should also use an auxiliary member variable to keep track of how many actual sensors exist onboard, also in case adding a new sensor is required).
baseprice, a float (price per day for the sensorless vehicle)
finalprice, a float (price per day with the increased cost of the car sensors)
available, a bool (1 = true; 0 = false; try to display true/false using the "boolalpha" flag)
and will have the following methods:
Default Constructor - will set the aforementioned data members to default initial values.
Parameterized Constructor - will create a new object based on the values passed into it.
Copy Constructor - will create a new object which duplicates an input RentalCar object.
Get methods for data members.
Set methods for data members except the m_sensors, and m_finalprice.
UpdatePrice - a method to update the finalprice after any potential changes (to the baseprice or the sensors)
Print - will print out all the car's data.
EstimateCost - will estimate the car's cost given (a parameter passed to it) a number of days to rent it for.
A Method to Add a CarSensor to the RentalCar object. You should try to make this an operator overload of (operator+). Hint: a RentalCar Class member method will be the better choice, since it will have access to private members.
The RentalAgency Class will contain the following private data members:
name, a C-style string
zipcode, an int array of size 5
inventory, an array of RentalCar objects with a size of 5
and will have the following methods:
Default Constructor - will set the aforementioned data members to default initial values.
Get/Set methods for name and zipcode data members - by-Value.
A GetInventoryItem method to index an object of the inventory data member - by-Reference. (Hint: This will allow you to access (read and write) to the agency's inventory like in Project_3.) You should try to make this an operator overload of (operator[]).
ReadAllData - read all of the data for the agency from a user-provided file.
PrintAllData - prints out all of the data for an agency (including car info).
PrintAvailableCars - prints out all of the data (including car info) only for the available cars of the agency.
The menu must have the following updated functionality:
Read ALL data from file. The file has been structured :The first line is the car agency info, followed by 5 cars.
For each car the order is: year make model tanksize baseprice {sensors} available.
The sensors are enclosed in {braces} and can be 0 up to 3 ws-separated names.
Print out ALL data for the agency and all its corresponding cars in a way that demonstrates this relationship (similarly to Project_3).
Print out the TOTAL number of sensors built to equip the agency's car fleet (total number by sensor type).
Find the most expensive available car - ask the user if they want to rent it - update that car's availability status if the user says yes.
Exit program.
The following minimum functionality and structure is required:
Ask the user for the input file name.
The list of sensors must be stored in an array of objects.
The list of cars must be stored in an array of objects.
Use character arrays (i.e., C-style) to hold your strings. No string data type!
Write multiple functions (Hint: each menu option should be a function).
At least one function must use pass by reference.
At least one function must use return by reference.
Variables, data members, functions, function signatures, should all be const in a perfect program, unless there is no other way for the program to work. (This might seem as an overstatement. However, try to remember the const keyword and design around it as much as you can).
Pointers must be used for all array manipulation.
Pointers must be used in function prototypes and function parameter lists (not brackets).
Pointers can only be moved by incrementing or decrementing:double d[3] = {1,2,3};
double* d_Pt = d;
for (int i=0; i<3; ++i,++d_Pt){ cout<<*d_Ptd; }
Or by setting the pointer back to the base address using the array name.d_Pt = d; cout<<endl<<*d_Pt<<endl;
Write your own string copy, string compare (or other) functions as needed, modify any existing versions to account for the updated specification about using pointers.
The other functionality and structure of the program should remain the same as Project #3, including writing to screen and file and restrictions on string libraries, global variables and constants, etc.
For this, and hence for any other Project of similar requirements, any output displayed to the user through the Console requires File Output (the same information, but appended to a running file (with a characteristic name, e.g. "proj4.log").