Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle:
- DEFAULT_FUEL_CONSUMPTION = 1.25
- def __init__(self, fuel, horse_power):
- self.fuel = fuel
- self.horse_power = horse_power
- self.fuel_consumption = self.DEFAULT_FUEL_CONSUMPTION
- def drive(self, kilometers):
- needed_fuel = kilometers * self.fuel_consumption
- if self.fuel >= needed_fuel:
- self.fuel -= needed_fuel
- class Motorcycle(Vehicle):
- pass
- class RaceMotorcycle(Motorcycle):
- DEFAULT_FUEL_CONSUMPTION = 8
- class CrossMotorcycle(Motorcycle):
- pass
- class Car(Vehicle):
- DEFAULT_FUEL_CONSUMPTION = 3
- class FamilyCar(Car):
- pass
- class SportCar(Car):
- DEFAULT_FUEL_CONSUMPTION = 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement