Advertisement
kompilainenn

Untitled

Nov 17th, 2023
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. class Human:
  2.     def __init__(self, name, gender):
  3.         self.name = name
  4.         self.gender = gender
  5.        
  6.     def introduce(self):
  7.         print(f'Hi! I\'m a {self.gender}, my name is {self.name}.')
  8.  
  9.  
  10. class SoftwareDeveloper(Human):
  11.     def __init__(self, name, gender, language):
  12.         super().__init__(name, gender)
  13.         self.language = language
  14.  
  15.     def introduce(self):
  16.         super().introduce()
  17.         print(f'I write {self.language}')
  18.  
  19.  
  20. class DeveloperSchool:
  21.     def __init__(self, language):
  22.         self.language = language
  23.         self.counter = 0
  24.        
  25.     def to_teach(self, human):
  26.         self.counter += 1
  27.         return SoftwareDeveloper(human.name, human.gender, self.language)
  28.    
  29.     def get_how_many_times(self):
  30.         print(f'We already trained how to use {self.language} {self.counter} person(s)')
  31.        
  32. class DebugSchool(DeveloperSchool):
  33.     def __init__(self, language):
  34.         super().__init__(language)
  35.    
  36. first = Human('Vasya', 'man')
  37. first.introduce()
  38. second = Human('Sveta', 'woman')
  39. second.introduce()
  40. third = Human('Mobile-1', 'helicopter')
  41. third.introduce()
  42. js_dev_school = DeveloperSchool('JS')
  43. cpp_dev_school = DeveloperSchool('C++')
  44. first = js_dev_school.to_teach(first)
  45. first.introduce()
  46. second = js_dev_school.to_teach(second)
  47. second.introduce()
  48. third = cpp_dev_school.to_teach(third)
  49. third.introduce()
  50. js_dev_school.get_how_many_times()
  51. cpp_dev_school.get_how_many_times()
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement