Design Parking System

Run Settings
LanguageJavaScript
Language Version
Run Command
class ParkingSystem { constructor (big, medium, small) { this.big = big; this.medium = medium; this.small = small; } addCar(carType) { switch (carType) { case 1: if (this.big === 0) return false; this.big--; return true; case 2: if (this.medium === 0) return false; this.medium--; return true; case 3: if (this.small === 0) return false; this.small--; return true; default: break; } } } const parkingSystem = new ParkingSystem(1,1,0); console.log(parkingSystem.addCar(1)); console.log(parkingSystem.addCar(2)); console.log(parkingSystem.addCar(3)); console.log(parkingSystem.addCar(1));
Editor Settings
Theme
Key bindings
Full width
Lines