class ParkingSystem {
private int[] emptyArea = new int[3];
public ParkingSystem(int big, int medium, int small) {
this.emptyArea[0] = big;
this.emptyArea[1] = medium;
this.emptyArea[2] = small;
}
public boolean addCar(int carType) {
if (this.emptyArea[carType - 1] != 0) {
this.emptyArea[carType - 1] -= 1;
return true;
}
return false;
}
}
'Coding Test > 리트코드' 카테고리의 다른 글
[리트코드/자바] 1920. Build Array from Permutation (0) | 2023.08.07 |
---|---|
[리트코드/자바] 1929. Concatenation of Array (0) | 2023.08.07 |