Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Boat.py
Original file line number Diff line number Diff line change
@@ -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())
4 changes: 4 additions & 0 deletions Car.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"