forked from vagabond-systems/forage-lyft-starter-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
car.py
53 lines (41 loc) · 1.61 KB
/
car.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from serviceable_interface import Serviceable
from engines.engine_interface import Engine
from batteries.battery_interface import Battery
from tires.tires_interface import Tires
from typing import List
class Car(Serviceable):
"""
Represents a car object that can be serviced.
This class provides a blueprint for creating car objects with an engine, battery, and tires.
It implements the Serviceable interface, allowing it to be checked for servicing needs.
Attributes:
engine (Engine): The engine of the car.
battery (Battery): The battery of the car.
tires (Tires): The tires of the car.
Methods:
needs_service(): Determines if the car needs servicing.
Usage:
car = Car(engine, battery, tires)
if car.needs_service():
print("The car needs servicing.")
else:
print("The car does not need servicing.")
"""
def __init__(self, engine: Engine, battery: Battery, tires: Tires) -> None:
"""
Initialize a Car object.
Args:
engine (Engine): The engine of the car.
battery (Battery): The battery of the car.
tires (Tires): The tires of the car.
"""
self.engine: Engine = engine
self.battery: Battery = battery
self.tires: Tires = tires
def needs_service(self) -> bool:
"""
Determines if the car needs servicing.
Returns:
bool: True if the car needs servicing, False otherwise.
"""
return self.engine.needs_service() or self.battery.needs_service() or self.tires.needs_service()