From fcc0261cd9c649839c09ac4b0de033af1cf90833 Mon Sep 17 00:00:00 2001 From: Gaurav Prasathong Date: Wed, 27 Nov 2024 19:51:11 -0500 Subject: [PATCH] Made Changes in Car py --- Car.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Car.py b/Car.py index 9741b1f..a08066b 100644 --- a/Car.py +++ b/Car.py @@ -12,3 +12,22 @@ def display_info(self): def honk(self): """Specific implementation for a car.""" return "Honk honk!" + + +class ElectricCar(Car): + def __init__(self, brand, model, year, doors, battery_capacity): + super().__init__(brand, model, year, doors) + self.battery_capacity = battery_capacity + + def display_info(self): + """Override the parent class method for an ElectricCar.""" + return (f"Electric Car: {self._brand} {self._model}, {self.doors} doors, " + f"{self.battery_capacity} kWh battery ({self._year})") + + def charge(self): + """Specific implementation for charging the electric car.""" + return f"{self._brand} {self._model} is now charging." + + def honk(self): + """Specific implementation for an electric car's horn.""" + return "Beep beep!" \ No newline at end of file