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
3 changes: 3 additions & 0 deletions Car.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ def display_info(self):
def honk(self):
"""Specific implementation for a car."""
return "Honk honk!"
my_car= Car(brand = 'Toyota', model = 'Supra', year = '2024', doors='2')
print(my_car.display_info())
print(my_car.honk())
4 changes: 4 additions & 0 deletions Motorcycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ def display_info(self):
def honk(self):
"""Specific implementation for a motorcycle."""
return "Meep meep!"
my_motorcycle = Motorcycle( brand = 'Yamaha', model = 'R7', year = '2023', has_sidecar = 'no' )
print(my_motorcycle.display_info())
print(my_motorcycle.honk())
print(my_motorcycle.fuel_up())
18 changes: 18 additions & 0 deletions Supercar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from Vehicle import Vehicle
class supercar(Vehicle):
def __init__(self, brand, model, year, engine, doors, horsepower,price):
super().__init__(brand, model, year)
self._engine = engine
self._doors = doors
self._horsepower = horsepower
self._price = price

def display_info(self):
return f"supercar: {self._brand} {self._model} {self._engine} engine {self._horsepower} horsepower, is {self._price} {self._doors} doors ({self._year})"

def honk(self):
return "Beep Beep"
my_supercar = supercar(brand = 'Buggati', model='Buggati Chiron', year = '2024', engine='W16', doors='2', horsepower='1,578',price='$4,999,999')
print(my_supercar.display_info())
print(my_supercar.honk())

3 changes: 3 additions & 0 deletions Truck.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ def display_info(self):
def honk(self):
"""Specific implementation for a truck."""
return "HOOOOONK!"
my_truck = Truck(brand = 'Peterbilt', model = 'Model 379', year = '2007', max_load= '54,000lbs')
print(my_truck.display_info())
print(my_truck.honk())
6 changes: 3 additions & 3 deletions Vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ def __init__(self, brand, model, year):
self._brand = brand
self._model = model
self._year = year

def display_info(self):
"""Abstract method to display vehicle info."""
return f"{self._brand} {self._model} ({self._year})"

def honk(self):
"""A general honk sound for all vehicles."""
return "Beep beep!"
return "Honk Honk!"

def fuel_up(self):
return "Full tank"

def brake(self):
print("Braking the car.")