Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MoneyBox:
- def __init__(self, capacity):
- self.max_coins=capacity
- self.coins_inside=0
- def can_add(self, v):
- return self.coins_inside+v<=self.max_coins
- def add(self, v):
- if self.can_add(v):
- self.coins_inside+=v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement