yordan_yordanov

1-a

Oct 26th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Storage:
  2. def __init__(self, capacity):
  3. self.capacity = int(capacity)
  4. self.storage = []
  5.  
  6. def add_product(self, product):
  7. if len(self.storage) < self.capacity:
  8. self.storage.append(product)
  9.  
  10. def get_products(self):
  11. return self.storage
  12.  
  13.  
  14. storage = Storage(4)
  15. storage.add_product("apple")
  16. storage.add_product("banana")
  17. storage.add_product("potato")
  18. storage.add_product("tomato")
  19. storage.add_product("bread")
  20.  
  21. print(storage.get_products())
  22.  
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment