Question: 20.3 ParkingLot Lab - 3 ParkingLot Lab - 3 Objective: The objective of this Lab is to write a ParkingLot class and a program to

 20.3 ParkingLot Lab - 3 ParkingLot Lab - 3 Objective: The

20.3 ParkingLot Lab - 3

ParkingLot Lab - 3

Objective:

The objective of this Lab is to write a ParkingLot class and a program to simulate the running of 3 parking lots at an airport.

Task 1: Create a program with the following specification:

  1. Create a program which contains a ParkingLot class, and stores information about a parking lot: name, vector of car names, daily rate, capacity.

  2. Your full program will help an airport run 3 parking lots: Economy, Standard, and Premium. When run, it should present a menu to allow a car to enter each of the 3 lots, exit each of the 3 lots, give stats on the 3 lots, or quit. Assume that the number of available spots in each lot is 10 and that the daily rate charged by each lot is $5, $10, and $20 for Economy, Standard, and Premium respectively.

  3. To support your program, your ParkingLot class should have the following traits:

    • Store 4 private variables: name, capacity, daily rate, and a vector of the cars currently in the lot. Since these are private, the exact variable names do not matter.
    • A setter and getter for each of the 4 variables listed above:
      • getLotName() , setLotName()
      • getAvailableSpots() , getTakenSpots()
      • getRate() , setRate() , setCapacity()
      • addCar() , removeCarByName() link*. Note that the removeCarByName() function will most likely require the use of vectors rather than arrays :)
    • Implement a getProfit() function which returns how much profit will be made with the current rate and occupancy for a day
    • Implement a printStats() function to print out the statistics for the lot, including the occupancy rate.
    • When compiled with g++ -Wall parking.cpp, no warnings are given.

Task 2: Properly style your code, clean up all warnings.

Be sure to put a header at the top of your code, including your name, date, and short description of the program. If coding in Cloud9, adding a -Wall on the compilation line (e.g. gpp -Wall parking.cpp) will print out all compiler suggested issues and count them as errors--I recommend doing this because Zybooks will do this too. These are not errors, but suspect issues. Fix your code to remove all warnings. Make sure no warnings are given when compiling with -Wall.

c++

main.cpp Load default template... 1 #include 3 #include 4 5 using namespace std; 6 7 8 class Parking Lot{ 9 private: 10 int dailyrate; 11 string name; 12 int capacity; 13 vector carNames; 14 15 public: 16 string getLotName(); 17 void setLotName(string lotName); 18 int getAvailableSpotsO; 19 int getTakenSpots; 20 int getRate; 21 void setRate(int rate); 22 void addCar(string car); 23 void removeCarByName(string car); 24 int getProfito; 25 void printStats(); 26 void setCapacity(int cap); 27 }; 28 29 30 int main(void) { 31 32 // ceate the lots 33 34 //set each lot rate 35 36 //set capacity for each lot 37 38 //set the lot nam e 39 40 //write menu with options for the user 41 42 43 return 0; 45} main.cpp Load default template... 1 #include 3 #include 4 5 using namespace std; 6 7 8 class Parking Lot{ 9 private: 10 int dailyrate; 11 string name; 12 int capacity; 13 vector carNames; 14 15 public: 16 string getLotName(); 17 void setLotName(string lotName); 18 int getAvailableSpotsO; 19 int getTakenSpots; 20 int getRate; 21 void setRate(int rate); 22 void addCar(string car); 23 void removeCarByName(string car); 24 int getProfito; 25 void printStats(); 26 void setCapacity(int cap); 27 }; 28 29 30 int main(void) { 31 32 // ceate the lots 33 34 //set each lot rate 35 36 //set capacity for each lot 37 38 //set the lot nam e 39 40 //write menu with options for the user 41 42 43 return 0; 45}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!