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 introduce(self):
- print(f'Hi! I\'m a {self.gender}, my name is {self.name}.')
- class SoftwareDeveloper(Human):
- def __init__(self, name, gender, language):
- super().__init__(name, gender)
- self.language = language
- def introduce(self):
- super().introduce()
- print(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(DeveloperSchool):
- def __init__(self, language):
- super().__init__(language)
- 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++')
- 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()
- js_dev_school.get_how_many_times()
- cpp_dev_school.get_how_many_times()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement