Advertisement
Redomine

копилка

Jul 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. class MoneyBox:
  2.  
  3. def __init__(self, capacity):
  4. self.max_coins=capacity
  5. self.coins_inside=0
  6.  
  7. def can_add(self, v):
  8. return self.coins_inside+v<=self.max_coins
  9.  
  10. def add(self, v):
  11. if self.can_add(v):
  12. self.coins_inside+=v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement