Tudjewuj

Фановый класс на Python

Feb 17th, 2023
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.27 KB | None | 0 0
  1. class Bird:
  2.     def __init__(self, color: str = "Белые", age: int = 0, canFly: bool = "true", emotion: int = 50):
  3.         self.color = color
  4.         self.age = age
  5.         self.canFly = canFly
  6.         self.emotion = emotion
  7.     def setAge(self, age: int):
  8.         self.age = age
  9.     def setColor(self, color: str):
  10.         self.color = color
  11.     def walk(self):
  12.         print("Ходит")
  13.     def fly(self):
  14.         if self.canFly:
  15.             if self.emotion < 30:
  16.                 print("Птичка в шоковом состоянии, она сейчас не может летать")
  17.             elif self.emotion < 50:
  18.                 print("Птичке сейчас плохо, она сейчас не может летать")
  19.             elif self.emotion < 70:
  20.                 print("Птичке хорошо! Она сейчас взлетит!")
  21.             elif self.emotion <= 100:
  22.                 print("Птичке отлично! Она взлетает!")
  23.         else:
  24.             print("Птичка не умеет летать")
  25. class Оstrich(Bird):
  26.     def __init__(self, color: str = "Чёрные", age: int = 0, maxSpeed: float = 50, emotion: int = 70):
  27.         super.__init__(color, age, False, emotion)
  28.         self.maxSpeed = maxSpeed
  29.     def sprint(self):
  30.         print("Сейчас птица идёт со скоростью "+str(self.maxSpeed)+" км/ч")
  31. class Pinguen(Bird):
  32.     def __init__(self, color: str = "Серый", age: int = 3, eating: bool = False, emotion: int = 70):
  33.         super.__init(color, age, False, emotion)
  34.         self.eating = eating
  35.     def eating(self):
  36.         if self.eating:
  37.             print("Пингвин кушает")
  38.         else:
  39.             print("Пингвин не голодный")
  40. # color: str = "Белые", age: int = 0, canFly: bool = True, emotion: int = 50
  41. class pigeon(Bird):
  42.     def __init__(self, color: str = "Чёрные", age: int = 0, maxSpeed: float = 10, emotion: int = 50):
  43.         super.__init__(color, age, False, emotion)
  44.         self.maxSpeed = maxSpeed
  45.     def maxSpeed(self):
  46.         print("У вашего голубя максимальная скорость "+str(self.maxSpeed))+" км/ч"
  47. golub = pigeon("Белый", 5, 3.3, 50)
  48. print(golub.maxSpeed())
Advertisement
Add Comment
Please, Sign In to add comment