|
@@ -0,0 +1,84 @@
|
|
|
+# Наследование
|
|
|
+
|
|
|
+# issubclass(sub, par)
|
|
|
+
|
|
|
+class Vehicle:
|
|
|
+
|
|
|
+ def __init__(self, name, max_speed, mileage):
|
|
|
+ self.name = name
|
|
|
+ self.max_speed = max_speed
|
|
|
+ self.mileage = mileage
|
|
|
+
|
|
|
+ def display_info(self):
|
|
|
+ print(f"Vehicle Name: {self.name}, Speed: {self.max_speed}, Mileage: {self.mileage}")
|
|
|
+
|
|
|
+
|
|
|
+class Bus(Vehicle):
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+class Person:
|
|
|
+
|
|
|
+ def __init__(self, name):
|
|
|
+ self.name = name
|
|
|
+
|
|
|
+ def get_name(self):
|
|
|
+ return self.name
|
|
|
+
|
|
|
+ def is_employee(self):
|
|
|
+ return False
|
|
|
+
|
|
|
+
|
|
|
+class Employee(Person):
|
|
|
+
|
|
|
+ def is_employee(self):
|
|
|
+ return True
|
|
|
+
|
|
|
+
|
|
|
+class Shape:
|
|
|
+ pass
|
|
|
+
|
|
|
+class Ellipse(Shape):
|
|
|
+ pass
|
|
|
+
|
|
|
+class Circle(Ellipse):
|
|
|
+ pass
|
|
|
+
|
|
|
+class Polygon(Shape):
|
|
|
+ pass
|
|
|
+
|
|
|
+class Triangle(Polygon):
|
|
|
+ pass
|
|
|
+
|
|
|
+class Rectangle(Polygon):
|
|
|
+ pass
|
|
|
+
|
|
|
+class Square(Rectangle):
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+def main():
|
|
|
+ shapes = [
|
|
|
+ Polygon(), Triangle(), Ellipse(), Polygon(), Triangle(), Ellipse(), Polygon(), Square(), Polygon(), Circle(),
|
|
|
+ Shape(), Polygon(), Triangle(), Circle(), Ellipse(), Shape(), Circle(), Rectangle(), Circle(), Circle(),
|
|
|
+ Square(), Square(), Circle(), Rectangle(), Rectangle(), Polygon(), Polygon(), Polygon(), Square(), Square(),
|
|
|
+ Rectangle(), Square(), Rectangle(), Polygon(), Circle(), Triangle(), Rectangle(), Shape(), Rectangle(),
|
|
|
+ Polygon(), Polygon(), Ellipse(), Square(), Circle(), Shape(), Polygon(), Ellipse(), Triangle(), Square(),
|
|
|
+ Polygon(), Triangle(), Circle(), Rectangle(), Rectangle(), Ellipse(), Triangle(), Rectangle(), Polygon(),
|
|
|
+ Shape(), Circle(), Rectangle(), Polygon(), Triangle(), Circle(), Polygon(), Rectangle(), Polygon(), Square(),
|
|
|
+ Triangle(), Circle(), Ellipse(), Circle(), Shape(), Circle(), Triangle(), Ellipse(), Square(), Circle(),
|
|
|
+ Triangle(), Polygon(), Square(), Polygon(), Circle(), Ellipse(), Polygon(), Shape(), Triangle(), Rectangle(),
|
|
|
+ Circle(), Square(), Triangle(), Triangle(), Ellipse(), Square(), Circle(), Rectangle(), Ellipse(), Shape(),
|
|
|
+ Triangle(), Ellipse(), Circle(), Shape(), Polygon(), Polygon(), Ellipse(), Rectangle(), Square(), Shape(),
|
|
|
+ Circle(), Triangle(), Circle(), Circle(), Circle(), Triangle(), Ellipse(), Polygon(), Circle(), Ellipse(),
|
|
|
+ Rectangle(), Circle(), Shape(), Polygon(), Polygon(), Triangle(), Rectangle(), Polygon(), Shape(), Circle(),
|
|
|
+ Shape(), Circle(), Triangle(), Ellipse(), Square(), Circle(), Triangle(), Ellipse(), Square(), Circle(),
|
|
|
+]
|
|
|
+
|
|
|
+ ret = [i for i in shapes if isinstance(i, (Polygon))]
|
|
|
+ print(len(ret))
|
|
|
+# 29 33 79
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ main()
|
|
|
+
|