From 710deeabfc4ab3353ff752e1f51c45ac094f1a4e Mon Sep 17 00:00:00 2001 From: Ripa Tanny Date: Tue, 26 Nov 2024 16:14:06 -0500 Subject: [PATCH 1/2] Added start_engine to Car and created Bus class --- Bus.py | 18 ++++++++++++++++++ Car.py | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 Bus.py diff --git a/Bus.py b/Bus.py new file mode 100644 index 0000000..6f6ed0a --- /dev/null +++ b/Bus.py @@ -0,0 +1,18 @@ +from Vehicle import Vehicle + +class Bus(Vehicle): + def __init__(self, brand, model, year, capacity): + super().__init__(brand, model, year) + self.capacity = capacity + + def display_info(self): + """Override the parent class method for a Bus.""" + return f"Bus: {self._brand} {self._model}, seats {self.capacity} passengers ({self._year})" + + def honk(self): + """Specific implementation for a bus.""" + return "Beep Beep! Make way for the bus!" + + def open_doors(self): + """Simulate opening the bus doors.""" + return "The bus doors are open." diff --git a/Car.py b/Car.py index 9741b1f..3e43300 100644 --- a/Car.py +++ b/Car.py @@ -12,3 +12,8 @@ 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!" + From e6b22a3da1033dffd5dc15c5c9a0e46c30fdf2c0 Mon Sep 17 00:00:00 2001 From: Ripa Tanny Date: Tue, 26 Nov 2024 16:26:06 -0500 Subject: [PATCH 2/2] Added start_engine method to Car class --- Vehicle.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Vehicle.py b/Vehicle.py index 1941f6b..260f28e 100644 --- a/Vehicle.py +++ b/Vehicle.py @@ -14,3 +14,6 @@ def honk(self): def fuel_up(self): return "Full tank" + + def brake(self): + print("Braking the car.")