From bc6d41cf3326aa0d8614840f50a6f6fe0803a4dd Mon Sep 17 00:00:00 2001 From: Andrik Date: Wed, 27 Nov 2024 22:30:57 -0500 Subject: [PATCH] Added supercar.py --- Car.py | 3 +++ Motorcycle.py | 4 ++++ Supercar.py | 18 ++++++++++++++++++ Truck.py | 3 +++ Vehicle.py | 6 +++--- 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Supercar.py diff --git a/Car.py b/Car.py index 9741b1f..758497c 100644 --- a/Car.py +++ b/Car.py @@ -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()) diff --git a/Motorcycle.py b/Motorcycle.py index 992790d..6ef68eb 100644 --- a/Motorcycle.py +++ b/Motorcycle.py @@ -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()) \ No newline at end of file diff --git a/Supercar.py b/Supercar.py new file mode 100644 index 0000000..b186857 --- /dev/null +++ b/Supercar.py @@ -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()) + \ No newline at end of file diff --git a/Truck.py b/Truck.py index 44773a9..aed58c7 100644 --- a/Truck.py +++ b/Truck.py @@ -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()) \ No newline at end of file diff --git a/Vehicle.py b/Vehicle.py index 260f28e..a0ba740 100644 --- a/Vehicle.py +++ b/Vehicle.py @@ -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.") +