1603. Design Parking System

1603. Design Parking System

class ParkingSystem {
 static int big = 0;
 static int medium = 0;
 static int small = 0;
    public ParkingSystem(int big1, int medium1, int small1) {
        big = big1;
        medium = medium1;
        small = small1;
    }
    
    public boolean addCar(int carType) {
        if(carType == 1){
            if(big >= 1){
                big--;
                return true;
            }else return false;
        }else if(carType == 2){
            if(medium >= 1){
                medium--;
                return true;
            } else return false;
        }else if (carType == 3){
            if(small >= 1){
                small--;
                return true;
            }else return false;
        }
        return false;
    }
}

/**
 * Your ParkingSystem object will be instantiated and called as such:
 * ParkingSystem obj = new ParkingSystem(big, medium, small);
 * boolean param_1 = obj.addCar(carType);
 */

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s