Skip to content

Commit 1f748aa

Browse files
authored
Create 1603-design-parking-system.js
1 parent 5142c72 commit 1f748aa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

1603-design-parking-system.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @param {number} big
3+
* @param {number} medium
4+
* @param {number} small
5+
*/
6+
const ParkingSystem = function(big, medium, small) {
7+
this['3'] = small
8+
this['2'] = medium
9+
this['1'] = big
10+
};
11+
12+
/**
13+
* @param {number} carType
14+
* @return {boolean}
15+
*/
16+
ParkingSystem.prototype.addCar = function(carType) {
17+
this[carType]--
18+
if(this[carType] < 0) {
19+
this[carType] = 0
20+
return false
21+
}
22+
return true
23+
};
24+
25+
/**
26+
* Your ParkingSystem object will be instantiated and called as such:
27+
* var obj = new ParkingSystem(big, medium, small)
28+
* var param_1 = obj.addCar(carType)
29+
*/

0 commit comments

Comments
 (0)