Advertisement
horozov86

need_for_spped_task_4

Jun 30th, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. class Vehicle:
  2.     DEFAULT_FUEL_CONSUMPTION = 1.25
  3.        
  4.     def __init__(self, fuel, horse_power):
  5.         self.fuel = fuel
  6.         self.horse_power = horse_power
  7.         self.fuel_consumption = self.DEFAULT_FUEL_CONSUMPTION
  8.        
  9.     def drive(self, kilometers):
  10.         needed_fuel = kilometers * self.fuel_consumption
  11.         if self.fuel >= needed_fuel:
  12.             self.fuel -= needed_fuel
  13.            
  14.            
  15. class Motorcycle(Vehicle):
  16.     pass
  17.  
  18. class RaceMotorcycle(Motorcycle):
  19.     DEFAULT_FUEL_CONSUMPTION = 8
  20.    
  21.  
  22. class CrossMotorcycle(Motorcycle):
  23.     pass
  24.  
  25. class Car(Vehicle):
  26.     DEFAULT_FUEL_CONSUMPTION = 3
  27.    
  28.  
  29. class FamilyCar(Car):
  30.     pass
  31.  
  32. class SportCar(Car):
  33.     DEFAULT_FUEL_CONSUMPTION = 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement