Question: in c++ void garage::arrival(const std::string &license) Create a car object and use it to print itself as part of a message announcing its arrival. If
in c++
void garage::arrival(const std::string &license)
Create a car object and use it to print itself as part of a message announcing its arrival. If the garage is already full of cars (as defined by parking_lot_limit) then print a message so indicating that fact(see the reference output.) If the garage is not already full then add the car to the parking_lot deque.
class garage
{ public: garage(size_t limit = 10) : parking_lot_limit(limit) {}
/// @param license The license of the car that has arrived. void arrival(const std::string &license);
/// @param license The license of the car that has departed. void departure(const std::string &license);
private: int next_car_id = { 1 };
std::deque parking_lot;
size_t parking_lot_limit; };
reference output:
| Car 8 with license plate "ZZZ 1111" has departed, | |
| car was moved 1 time in the garage. | |
| Car 11 with license plate "WHO IS" has arrived. | |
| Car 12 with license plate "J RIPPER" has arrived. | |
| Car 13 with license plate "CEM 1" has arrived. | |
| Car 14 with license plate "Z123" has arrived. | |
| Car 15 with license plate "QQ 99" has arrived. | |
| Car 7 with license plate "XC 344" has departed, | |
| car was moved 2 times in the garage. | |
| Car 16 with license plate "1" has arrived. | |
| Car 17 with license plate "11" has arrived. | |
| But the garage is full! | |
| 'X': invalid action! | |
| Car 9 with license plate "MARYANN" has departed, | |
| car was moved 1 time in the garage. | |
| Car 6 with license plate "UV 2" has departed, | |
| car was moved 4 times in the garage. | |
| No car with license plate "XXX 123" is in the garage. | |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
