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
12 changes: 12 additions & 0 deletions Car.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ 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 display_info method to include battery information."""
return f"Electric Car: {self._brand} {self._model}, {self.doors} doors ({self._year}) - Battery: {self.battery_capacity} kWh"

def charge(self):
"""New method specific to ElectricCar."""
return "Charging the battery!"