- 数组
class ParkingSystem {
private cars: number[];
constructor(big: number, medium: number, small: number) {
this.cars = [big, medium, small];
}
addCar(carType: number): boolean {
if (this.cars[carType - 1] <= 0) {
return false;
}
--this.cars[carType - 1];
return true;
}
}
/**
* Your ParkingSystem object will be instantiated and called as such:
* var obj = new ParkingSystem(big, medium, small)
* var param_1 = obj.addCar(carType)
*/