Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car:
- wheels = "four"
- doors = 4
- working_engine = False
- engine_start_msg = "Engine has started"
- engine_stop_msg = "Engine has stopped"
- def __init__(self, brand: str = "", model: str = ""):
- self.brand = brand
- self.model = model
- def start_engine(self):
- self.working_engine = True
- print(self.engine_start_msg)
- def stop_engine(self):
- self.working_engine = False
- print(self.engine_stop_msg)
- class ElectricCar(Car):
- engine_start_msg = "Electric motor has started"
- engine_stop_msg = "Electric motor has stopped"
- def __init__(self, battery_capacity: int, brand: str = "", model: str = ""):
- super().__init__(brand, model)
- self.battery_capacity = battery_capacity
- my_car = Car()
- some_car1 = Car("Ford", "Mustang")
- some_car2 = Car(model="Camaro")
- some_car1.start_engine()
- some_car2.start_engine()
- my_electric_car = ElectricCar(100, "Tesla", "Model 3")
- my_electric_car.start_engine()
- my_electric_car2 = ElectricCar(60, "Toyota", "Prius")
- my_electric_car2.start_engine()
- my_electric_car2.stop_engine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement