1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| class ParkingSystem { private: int b, m, s; public: ParkingSystem(int big, int medium, int small): b(big), m(medium), s(small) { } bool addCar(int carType) { switch (carType) { case 1: return b-- > 0; case 2: return m-- > 0; case 3: return s-- > 0; } return false; } };
|