Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. class CoffeeDrink:
  2.  
  3.     __price = 0
  4.  
  5.     def __init__(self, name):
  6.        
  7.         self.name = name
  8.         self.drink_data ={
  9.                             'name': self.name,
  10.                             'ingredients': {},
  11.                             'price': self.__price,
  12.                             'button': 0,
  13.                             'available': False
  14.                         }
  15.  
  16.  
  17.     def __str__(self):
  18.         """
  19.         """
  20.         return f"{self.name}, {self.drink_data['price']} {self.__price}"
  21.  
  22.  
  23.    
  24.     @property
  25.     def set_price(self):
  26.         return self.__price
  27.  
  28.     @set_price.setter
  29.     def set_price(self, amount):
  30.         if amount > 10:
  31.             self.__price = 15
  32.         elif amount < 0:
  33.             self.__price = 0
  34.         else:
  35.             self.__price = amount
  36.  
  37. if __name__ == '__main__':
  38.    
  39.     d = CoffeeDrink('Amerikana')
  40.     d.set_price = 100000
  41.    
  42.     print(d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement