본문 바로가기

Coding Test/리트코드

[리트코드/자바] 1603. Design Parking System

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;
    }
}