SHARE
TWEET

Untitled

a guest Jun 27th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from Item import Item
  2.  
  3. class Container:
  4.     id = 30
  5.  
  6.     def __init__(self, objects=None):
  7.         if objects is None:
  8.             objects = {}
  9.         self.objects = objects
  10.  
  11.     def add_object(self, obj: Item):
  12.         self.objects.update({id: obj})
  13.         Container.id = container.id + 1
  14.  
  15.     def get_length(self):
  16.         return len(self.objects)
  17.  
  18.     def find_price_of_given_id(self, id):
  19.         # return self.objects.get(id).get_price()
  20.         pass
  21.  
  22.  
  23. Cola = Item(20)
  24. print(Cola.get_amount())
  25. container = Container()
  26. container.add_object(Cola)
  27. print(container.objects.items())
  28.      
  29. class Item:
  30.     def __init__(self, price,amount=5):
  31.         self.amount = amount
  32.         self.price = price
  33.  
  34.     def get_price(self):
  35.         return self.price
  36.  
  37.     def get_amount(self):
  38.         return self.amount
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top