Advertisement
Guest User

Untitled

a guest
Sep 25th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. class BellTower:
  2. def __init__(self, list_bells):
  3. self.list_bells = list_bells
  4.  
  5. def sound(self):
  6. for i in self.bells_list:
  7. i.sound()
  8. print("...")
  9.  
  10. def append(self, item):
  11. self.list_bells.append(item)
  12.  
  13. def print_info(self):
  14. self.string = ""
  15. for i in sorted(self.dict_info):
  16. self.string += f"{i}: {self.dict_info.get(i)}, "
  17. if self.info:
  18. if self.dict_info:
  19. self.string = self.string[:-2] + "; "
  20. for i in self.info:
  21. self.string += f"{i}, "
  22. self.string = self.string[:-2]
  23. if self.string:
  24. print(self.string)
  25. else:
  26. print("-")
  27.  
  28.  
  29. class BigBell(BellTower):
  30. def __init__(self, *args, **kwargs):
  31. self.dict_info = kwargs
  32. self.info = args
  33. self.count = 1
  34.  
  35. def sound(self):
  36. if self.count == 1:
  37. self.count = 2
  38. print("ding")
  39. else:
  40. self.count = 1
  41. print("dong")
  42.  
  43.  
  44. class LittleBell(BellTower):
  45. def __init__(self, *args, **kwargs):
  46. self.dict_info = kwargs
  47. self.info = args
  48.  
  49. def sound(self):
  50. print("ding")
  51.  
  52.  
  53. bt = BellTower(BigBell("бронзовый"),
  54. LittleBell("медный", нота="ля"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement