MeGaDeTH_91

Untitled

Apr 5th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. from abc import ABC, abstractmethod
  2.  
  3.  
  4. class Factory(ABC):
  5. def __init__(self, name: str, capacity: int):
  6. self.name = name
  7. self.capacity = capacity
  8. self.ingredients = {}
  9.  
  10. @abstractmethod
  11. def add_ingredient(self, ingredient_type: str, quantity: int):
  12. pass
  13.  
  14. @abstractmethod
  15. def remove_ingredient(self, ingredient_type: str, quantity: int):
  16. pass
  17.  
  18. def can_add(self, value: int):
  19. free_slots = self.capacity - sum(self.ingredients.values())
  20.  
  21. if free_slots >= value:
  22. return True
  23.  
  24. return False
Advertisement
Add Comment
Please, Sign In to add comment