-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9599aeb
commit 0e2ac77
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <array> | ||
#include <cstddef> | ||
|
||
using namespace std; | ||
class ParkingSystem { | ||
private: | ||
const int big = 1; | ||
const int medium = 2; | ||
const int small = 3; | ||
|
||
std::array<int, 4> parkingLots; | ||
|
||
public: | ||
ParkingSystem(int big, int medium, int small) : parkingLots{{}} { | ||
parkingLots[this->big] = big; | ||
parkingLots[this->medium] = medium; | ||
parkingLots[this->small] = small; | ||
} | ||
|
||
bool addCar(int carType) { | ||
if (parkingLots[carType] == 0) { | ||
return false; | ||
} | ||
--parkingLots[carType]; | ||
return true; | ||
} | ||
}; | ||
|
||
/** | ||
* Your ParkingSystem object will be instantiated and called as such: | ||
* ParkingSystem* obj = new ParkingSystem(big, medium, small); | ||
* bool param_1 = obj->addCar(carType); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters