Advertisement
Chl_Snt

miron oop

Jun 26th, 2023
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. class RemoteControl:
  2.     def __init__(self):
  3.         self.ID = None
  4.         self.power = None
  5.         self.battery = None
  6.         self.antenna = None
  7.  
  8.     def move(self, p):
  9.         self.send(p)
  10.  
  11.     def send(self, signal):
  12.         print(f"{self.ID}: Сигнал {signal} отправлен")
  13.         self.battery -= 1
  14.  
  15.  
  16.     def info(self):
  17.         print(self.__dict__)
  18.  
  19.  
  20. class HelicopterRC(RemoteControl):
  21.     def __init__(self, ID):
  22.         super().__init__()
  23.         self.ID = ID
  24.         self.power = True
  25.         self.battery = 100
  26.         self.antenna = True
  27.  
  28.     def fly(self, p):
  29.         self.send(f"fly: {p}")
  30.  
  31.  
  32. class AutoRC(RemoteControl):
  33.     def __init__(self, ID):
  34.         super().__init__()
  35.         self.ID = ID
  36.         self.power = True
  37.         self.battery = 90
  38.  
  39.     def lights_on(self):
  40.         self.send(f"lights: {True}")
  41.  
  42.  
  43. class TV_RC(RemoteControl):
  44.     def __init__(self, ID):
  45.         super().__init__()
  46.  
  47.  
  48.  
  49. h = HelicopterRC("12F")
  50. h.battery -= 42
  51. h.info()
  52. h.move(-100)
  53. h.fly(900)
  54.  
  55. print()
  56.  
  57. h2 = HelicopterRC("59T")
  58. h2.antenna = False
  59. h2.info()
  60. h2.move(50)
  61. h2.fly(-50)
  62. h2.info()
  63.  
  64. print()
  65.  
  66. auto = AutoRC("44K")
  67. auto.info()
  68. auto.lights_on()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement