Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Human:
- def __init__(self, name, gender):
- self.name = name
- self.gender = gender
- def create_str_intro(self):
- return f'Hi! I\'m a {self.gender}, my name is {self.name}.'
- def introduce(self):
- print(self.create_str_intro())
- class SoftwareDeveloper(Human):
- def __init__(self, name, gender, language):
- super().__init__(name, gender)
- self.language = language
- def create_str_intro(self):
- return super().create_str_intro() + f' I write {self.language}.'
- class DeveloperSchool:
- def __init__(self, language):
- self.language = language
- self.counter = 0
- def to_teach(self, human):
- self.counter += 1
- return SoftwareDeveloper(human.name, human.gender, self.language)
- def get_how_many_times(self):
- print(f'We already trained how to use {self.language} {self.counter} person(s)')
- class DebugSchool():
- def __init__(self, school):
- self.school = school
- def to_teach(self, human):
- return self.school.to_teach(human)
- def get_how_many_times(self):
- self.school.get_how_many_times()
- first = Human('Vasya', 'man')
- first.introduce()
- second = Human('Sveta', 'woman')
- second.introduce()
- third = Human('Mobile-1', 'helicopter')
- third.introduce()
- js_dev_school = DeveloperSchool('JS')
- cpp_dev_school = DeveloperSchool('C++')
- py_dev_school = DeveloperSchool('Python')
- first = js_dev_school.to_teach(first)
- first.introduce()
- # second = js_dev_school.to_teach(second)
- # second.introduce()
- #
- # third = cpp_dev_school.to_teach(third)
- # third.introduce()
- debug_school_python = DebugSchool(py_dev_school)
- first = debug_school_python.to_teach(first)
- first.introduce()
- debug_school_python.get_how_many_times()
- # js_dev_school.get_how_many_times()
- # cpp_dev_school.get_how_many_times()
- # py_dev_school.get_how_many_times()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement