-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1603-Design-Parking-System.cpp
More file actions
executable file
·59 lines (55 loc) · 1.32 KB
/
1603-Design-Parking-System.cpp
File metadata and controls
executable file
·59 lines (55 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class ParkingSystem {
public:
// Store number of spaces of a certain size
// and the number of those spaces filled
int numBig = 0;
int bigFilled = 0;
int numMedium = 0;
int mediumFilled = 0;
int numSmall = 0;
int smallFilled = 0;
ParkingSystem(int big, int medium, int small) {
numBig = big;
numMedium = medium;
numSmall = small;
}
bool addCar(int carType) {
if(carType == 1)
{
if(bigFilled < numBig)
{
bigFilled++;
return true;
}
else
return false;
}
if(carType == 2)
{
if(mediumFilled < numMedium)
{
mediumFilled++;
return true;
}
else
return false;
}
if(carType == 3)
{
if(smallFilled < numSmall)
{
smallFilled++;
return true;
}
else
return false;
}
// No spaces for other sizes
return false;
}
};
/**
* Your ParkingSystem object will be instantiated and called as such:
* ParkingSystem* obj = new ParkingSystem(big, medium, small);
* bool param_1 = obj->addCar(carType);
*/