Skip to content
Open
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
19 changes: 19 additions & 0 deletions Car.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"