Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Inventory:
- items = []
- def __init__(self, capacity: int):
- self.__capacity = capacity
- self.initial_capacity = self.__capacity
- def add_item(self, item: str):
- if self.__capacity > 0:
- self.items.append(item)
- self.__capacity -= 1
- else:
- return 'not enough room in the inventory'
- def get_capacity(self):
- return self.initial_capacity
- def __repr__(self):
- rep = f"Items: {', '.join(self.items)}.\nCapacity left: {self.__capacity}"
- return rep
Advertisement
Add Comment
Please, Sign In to add comment