-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDesignParkingSystem.java
More file actions
41 lines (38 loc) · 1003 Bytes
/
DesignParkingSystem.java
File metadata and controls
41 lines (38 loc) · 1003 Bytes
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
class ParkingSystem {
private int big ;
private int medium;
private int small;
public ParkingSystem(int big, int medium, int small) {
this.big = big;
this.medium = medium;
this.small = small;
}
public boolean addCar(int carType) {
if(carType == 1){
if(this.big-1 < 0) return false;
else {
this.big--;
return true;
}
}
else if(carType == 2){
if(this.medium-1 < 0) return false;
else {
this.medium--;
return true;
}
}
else{
if(this.small-1 < 0) return false;
else {
this.small--;
return true;
}
}
}
}
/**
* Your ParkingSystem object will be instantiated and called as such:
* ParkingSystem obj = new ParkingSystem(big, medium, small);
* boolean param_1 = obj.addCar(carType);
*/