Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BellTower:
- def __init__(self, list_bells):
- self.list_bells = list_bells
- def sound(self):
- for i in self.bells_list:
- i.sound()
- print("...")
- def append(self, item):
- self.list_bells.append(item)
- def print_info(self):
- self.string = ""
- for i in sorted(self.dict_info):
- self.string += f"{i}: {self.dict_info.get(i)}, "
- if self.info:
- if self.dict_info:
- self.string = self.string[:-2] + "; "
- for i in self.info:
- self.string += f"{i}, "
- self.string = self.string[:-2]
- if self.string:
- print(self.string)
- else:
- print("-")
- class BigBell(BellTower):
- def __init__(self, *args, **kwargs):
- self.dict_info = kwargs
- self.info = args
- self.count = 1
- def sound(self):
- if self.count == 1:
- self.count = 2
- print("ding")
- else:
- self.count = 1
- print("dong")
- class LittleBell(BellTower):
- def __init__(self, *args, **kwargs):
- self.dict_info = kwargs
- self.info = args
- def sound(self):
- print("ding")
- bt = BellTower(BigBell("бронзовый"),
- LittleBell("медный", нота="ля"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement