class ParkingSystem(object):
def __init__(self, big, medium, small):
"""
:type big: int
:type medium: int
:type small: int
"""
self.big = big
self.medium = medium
self.small = small
def addCar(self, carType):
"""
:type carType: int
:rtype: bool
"""
if carType == 1 and self.big > 0:
self.big -= 1
return True
elif carType == 2 and self.medium > 0:
self.medium -= 1
return True
elif carType == 3 and self.small > 0:
self.small -= 1
return True
else :
return False
# Your ParkingSystem object will be instantiated and called as such:
# obj = ParkingSystem(big, medium, small)
# param_1 = obj.addCar(carType)
10-04
391
07-17
560
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交