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
14 changes: 14 additions & 0 deletions Bike.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from Vehicle import Vehicle

class Bike(Vehicle):
def __init__(self, brand, model, year, bike_type):
super().__init__(brand, model, year)
self.bike_type = bike_type

def display_info(self):
"""Override the parent class method for a Bike."""
return f"Bike: {self._brand} {self._model}, Type: {self.bike_type} ({self._year})"

def honk(self):
"""Specific implementation for a bike."""
return "Ring Ring!"
22 changes: 13 additions & 9 deletions Truck.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from Vehicle import Vehicle

class Truck(Vehicle):
def __init__(self, brand, model, year, max_load):
super().__init__(brand, model, year)
self.max_load = max_load
def __init__(self, brand, model, year, max_load):
super().__init__(brand, model, year)
self.max_load = max_load

def display_info(self):
"""Override the parent class method for a Truck."""
return f"Truck: {self._brand} {self._model}, Max load: {self.max_load} tons ({self._year})"
def display_info(self):
"""Override the parent class method for a Truck."""
return f"Truck: {self._brand} {self._model}, Max load: {self.max_load} tons ({self._year})"

def honk(self):
"""Specific implementation for a truck."""
return "HOOOOONK!"
def honk(self):
"""Specific implementation for a truck."""
return "HOOOOONK!"

def is_old(self):
"""Specific method to check truck age"""
return year < 1960