python class Car: def __init__(self, brand, color): self.brand = brand self.color = color def start_engine(self): print(f"The {self.color} car is starting the engine.") def drive(self, distance): print(f"The {self.color} car is driving {distance} kilometers.") def stop_engine(self): print(f"The {self.color} car has stopped the engine.") my_car = Car("Toyota", "red") my_car.start_engine() my_car.drive(100) my_car.stop_engine()


上一篇:
下一篇:
切换中文