LeatherDeer

Untitled

Nov 18th, 2022
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. class ParkingSystem {
  2.     int[] slots;
  3.  
  4.     public ParkingSystem(int big, int medium, int small) {
  5.         slots = new int[3];
  6.         slots[0] = big;
  7.         slots[1] = medium;
  8.         slots[2] = small;
  9.     }
  10.    
  11.     public boolean addCar(int carType) {
  12.         if (slots[carType - 1] > 0) {
  13.             slots[carType - 1] -= 1;
  14.             return true;
  15.         }
  16.         return false;
  17.     }
  18. }
Add Comment
Please, Sign In to add comment