diff --git a/Boat.py b/Boat.py new file mode 100644 index 0000000..cdafe7c --- /dev/null +++ b/Boat.py @@ -0,0 +1,21 @@ +from Vehicle import Vehicle + +class Boat(Vehicle): + def __init__(self, brand, model, year, boat_type): + super().__init__(brand, model, year) + self.boat_type = boat_type + + def display_info(self): + """Override the parent class method for a Boat.""" + return f"Boat: {self._brand} {self._model}, Type: {self.boat_type} ({self._year})" + + def honk(self): + """Specific implementation for a boat.""" + return "Hooo hooo!" + + +if __name__ == "__main__": + my_boat = Boat("Jiajian", "242X", 2021, "Speedboat") + print(my_boat.display_info()) + print(my_boat.honk()) + print(my_boat.sail()) \ No newline at end of file diff --git a/Car.py b/Car.py index 9741b1f..12ca380 100644 --- a/Car.py +++ b/Car.py @@ -12,3 +12,7 @@ def display_info(self): def honk(self): """Specific implementation for a car.""" return "Honk honk!" + + def start_engine(self): + """Simulate starting the engine of the car.""" + return f"{self._brand} {self._model}'s engine has started!" \ No newline at end of file