Question
in c++ void garage::departure(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::departure(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.
Do not use the erase() member function on the deque object.
Do not create any global constants.
class car { public: car(int id, const std::string &license) : id(id), license(license) {}
/// Call this to increment the number of times the car has been moved. void move(){++num_moves;}
/// @return the number of times that the car has been moved. int get_num_moves() const {return num_moves}; /// @return A reference to the license for this car. const std::string &get_license() const {return license;}
/** * Overload the << so this can print itself as: * Car X with license plate "Y" ******************************************************************/ friend std::ostream& operator<<(std::ostream& lhs, const car& rhs) { lhs << "Car " << rhs.id << " with license plate \"" << rhs.license << "\""; return lhs; }
private: int id; ///< The ID number for this car (assigned by the garage) std::string license; ///< license plate of this car. int num_moves = {0}; ///< how many times the car was moved within the garage. }; 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
Step 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