In: Computer Science
write a c++ code for following application You have been hired by XYZ Car Rental to develop a software system for their business.
Your program will have two unordered lists, one of Cars and one of Reservations. 
The Car class will have the following data:
        string plateNumber (this is the key)
        string make
        string model
        enum vehicleType (VehicleType Enumeration of options: sedan, suv, exotic)
        double pricePerDay
        bool isAvailable
        isAvailable should be set to true on initialization, and a public setter method should
        be exposed SetAvailable(bool available); 
Reservation will have the following:
        string name (key)
        string vehicleRented (plate of the car which is our key for the list)
The Program class will be composed of the two lists. 
There will also be a method to display a menu that will have the following options, 
Create a method to process the user's input and call appropriate methods to perform the operation requested.
(Use a switch statement and call the appropriate methods based on the number the user puts in)
    -------------------------------------------
    XYZ Car Rental
    -------------------------------------------
    1. List all cars
    2. Add car to inventory
    3. Remove car from inventory
    4. List all reservations
    5. Add a reservations
    6. Cancel reservation
    7. Exit
Option 1: 
    List all the cars in the unordered list of cars
     (Overload the << operator like my example to print each car's info)
Option 2: 
    Prompt for all the information for a vehicle. 
    Create the vehicle and add it to the list of available vehicles
Option 3:
    Remove a vehicle from the list of available cars. 
    If the car is not available (a user has rented it) return an error message and don't remove the vehicle
Option 4: 
    List all the reservations. Use the key in the reservation to retrieve the vehicle details from the list of vehicles
Option 5: 
    Prompt the user for a name. 
    List all the cars that are available (isAvailable=true):
        1. Nissan Sentra (sedan) $24/day
            2. ...
            n+1. Cancel
    
    Prompt the user to enter an option. Your list will need to implement a GetItemAtIndex
    method which will let you select a vehicle based on the menu option. For example if the user selects 1, you would call GetItemAtIndex(choice - 1). 
    Make sure this returns a car reference: Car& GetItemAtIndex(int index) 
    Create a reservation object with this car's plate and the user's name, and call the car's SetAvailable method with  false passed as the argument; 
    If cancel is pressed, show all the original options again
Option 6:
    Propt the user for a name. Remove the reservation object from the list if that user's name is a key. 
    Use the plate number to find the car in the list and set available to true (Make sure the GetItem method returns a reference)
At the end of each option's method (except Exit) make sure ot list the menu options again.
For Exit, quit the program. 
#include<iostream>
#define MAX 100
using namespace std;
enum vehicleType{sedan,suv,exotic};
class car
{
   private:
       string plateNumber;
       string make;
       string model;
       //vehicleType VT;
       double pricePerDay;
       bool isAvailable;
   public:
       car()
       {
          
isAvailable=true;
       }
       string getplateNumber()
       {
           return
plateNumber;
       }
       void setPlateNumber(string
plateNumber_)
       {
          
plateNumber=plateNumber_;
       }
       string getMake()
       {
           return
make;
       }
       void setMake(string make_)
       {
          
make=make_;
       }
       string getModel()
       {
           return
model;
       }
       void setModel(string model_)
       {
          
model=model_;
       }
//       int getVehicleType()
//       {
//           return
VT;
//       }
//       void setVehicleType(vehicleType
VT_)
//       {
//           VT=VT_;
//       }
       double getPrice()
       {
           return
pricePerDay;
       }
       void setPrice(double price)
       {
          
pricePerDay=price;
       }
       bool getIsAvailable()
       {
           return
isAvailable;
       }
       void setIsAvailable(bool val)
       {
          
isAvailable=val;
       }
};
class reservation
{
   private:
       string name;
       string vehicleRented;
   public:
       string getName()
       {
           return
name;
       }
       void setName(string name_)
       {
          
name=name_;
       }
       string getVehicleRented()
       {
           return
vehicleRented;
       }
       void setVehicleRented(string
val)
       {
          
vehicleRented=val;
       }
};
int getChoice()
{
   int ch;
   cout<<"1. List all cars\n";
   cout<<"2. Add car to inventory\n";
   cout<<"3. Remove car from inventory\n";
   cout<<"4. List all reservations\n";
   cout<<"5. Add a reservation\n";
   cout<<"6. Cancel reservation\n";
   cout<<"7. Exit\n";
   cout<<" Enter your choice:";
   cin>>ch;
   return ch;
}
class carList
{
   private:
       class car list[MAX];
       int size;
   public:
       carList()
       {
           size=0;
       }
       car GetItemByIndex(int index)
       {
          
if(index<size)
           {
          
    return list[index];
           }
           else
           {
          
    cout<<"\nInvalid Index\n";
           }
  
       }
       void ViewCar()
       {
          
if(size>0)
           {
          
   
          
    class car tempCar;
          
    for(int i=0;i<size;i++)
          
    {
          
       
tempCar=GetItemByIndex(i);
          
       
          
        cout<<"Plate Number:
"<<tempCar.getplateNumber()<<" Make:
"<<tempCar.getMake()<<" Model:
"<<tempCar.getModel()<<" VehicleType:
"/*<<tempCar.getVehicleType()*/<<" Price Per Day:
"<<tempCar.getPrice()<<" Available:
"<<(tempCar.getIsAvailable()?"Yes":"No")<<endl;
          
    }
           }
           else
           {
          
    cout<<"\nNo data in the list\n";
           }
       }
       void addNewCar()
       {
           class car
newCar;
string tempdata;
double price;
//VehicleType VT;
cout<<"Car plate detail:";
cin>>tempdata;
newCar.setPlateNumber(tempdata);
cout<<"Car make detail:";
cin>>tempdata;
newCar.setMake(tempdata);
cout<<"Car model detail:";
cin>>tempdata;
newCar.setModel(tempdata);
// cout<<"Car Vehicle Type detail:";
// cin<<VT;
// newCar.setVehicleType(VT);
cout<<"Car price detail:";
cin>>price;
newCar.setPrice(price);
list[size]=newCar;
size++;
}
int getVehicleByPlateNumber(string plateNumber)
{
   for(int i=0;i<size;i++)
   {
      
if(list[i].getplateNumber()==plateNumber)
       {
           return i;
          
    }
           }
   return -1;
       }
       void RemoveCar()
       {
          
          
cout<<"\nEnter Plate number:";
           string
vehiclePlate_;
          
cin>>vehiclePlate_;
           int
index=getVehicleByPlateNumber(vehiclePlate_);
          
if(index>=0)
           {
          
    list[index]=list[size-1];
          
    size--;
           }
           else
           {
          
    cout<<"\nno vehicle found\n";
           }
       }
       void setAvailablityByindex(int
index,bool val)
       {
          
if(index<size&&index>=0)
           {
          
    list[index].setIsAvailable(val);
           }
       }
       bool getAvailablityByindex(int
index)
       {
          
if(index<size&&index>=0)
           {
          
    return list[index].getIsAvailable();
           }
           return
false;
       }
  
};
class reservationList
{
   private:
       class reservation list[MAX];
       int size;
   public:
       reservationList()
       {
           size=0;
       }
       reservation GetItemByIndex(int
index)
       {
          
if(index<size)
           {
          
    return list[index];
           }
           else
           {
          
    cout<<"\nInvalid Index\n";
           }
  
       }
       void ViewReservation()
       {
          
if(size>0)
           {
          
   
          
    class reservation tempReservation;
          
    for(int i=0;i<size;i++)
          
    {
          
       
tempReservation=GetItemByIndex(i);
          
       
          
        cout<<"Name:
"<<tempReservation.getName()<<" Vehicle Rented:
"<<tempReservation.getVehicleRented()<<endl;
          
    }
           }
           else
           {
          
    cout<<"\nNo data in the list\n";
           }
       }
       void addNewReservation(class
carList *cList)
       {
           class
reservation newreservation;
string tempdata;
double price;
cout<<"Customer name:";
cin>>tempdata;
newreservation.setName(tempdata);
cout<<"Vehicle Rented(Plate Number):";
cin>>tempdata;
int index=cList->getVehicleByPlateNumber(tempdata);
if(index>=0)
{
   if(cList->getAvailablityByindex(index))
   {
      
cList->setAvailablityByindex(index,false);
      
newreservation.setVehicleRented(tempdata);
       list[size]=newreservation;
       size++;
          
    }
          
    else
          
    {
          
        cout<<"\nVehicle Not
Available\n";
          
    }
           }
  
}
int getReservationByName(string name)
{
   for(int i=0;i<size;i++)
   {
       if(list[i].getName()==name)
       {
           return i;
          
    }
           }
   return -1;
       }
       void cancelReservation(class
carList *cList)
       {
          
          
cout<<"\nEnter name:";
           string
name;
          
cin>>name;
           int
index=getReservationByName(name);
          
if(index>=0)
           {
          
   
//getReservationByIndex(index).getVehicleRented();
          
    int
carIndex=cList->getVehicleByPlateNumber(GetItemByIndex(index).getVehicleRented());
          
   
          
   
cList->setAvailablityByindex(carIndex,true);
          
    list[index]=list[size-1];
          
    size--;
           }
           else
           {
          
    cout<<"\nNo reservation found\n";
           }
       }
  
};
void callFunction(int ch, class carList *cList,class
reservationList *rList)
{
switch(ch)
{
case 1:
cList->ViewCar();
break;
case 2:
cList->addNewCar();
break;
case 3:
cList->RemoveCar();
break;
case 4:
rList->ViewReservation();
break;
case 5:
rList->addNewReservation(cList);
break;
case 6:
rList->cancelReservation(cList);
break;
default:
if(ch!=7)
cout<<"\nInvalid choice\n";
  
}
}
int main()
{
int ch = -1;
class carList cList;
class reservationList rList;
while (ch != 7)
{
ch = getChoice ();
callFunction(ch,&cList,&rList);
}
return 0;
}