Coverage for car_factory.py: 100%
34 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-09 21:08 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-09 21:08 +0000
1"""This module implements the CarFactory class, which is responsible for creating car objects.
2"""
3from datetime import datetime
4from abc import ABC
5from car import Car
7# import engines
8from engine.capulet_engine import CapuletEngine
9from engine.willoughby_engine import WilloughbyEngine
10from engine.sternman_engine import SternmanEngine
11# import batteries
12from battery.spindler import SpindlerBattery
13from battery.nubbin import NubbinBattery
16class CarFactory(ABC):
17 """This class is responsible for creating different types of Car objects.
18 """
20 def create_calliope(self, current_date: datetime,
21 last_service_date: datetime,
22 current_mileage: int, last_service_mileage: int) -> Car:
24 """Creates a Calliope car object.
26 Args:
27 current_date (datetime): The current date.
28 last_service_date (datetime): The date when the car was last serviced.
29 current_mileage (int): The current mileage of the car.
30 last_service_mileage (int): The mileage when the car was last serviced.
32 Returns:
33 Car: car object.
34 """
35 engine = CapuletEngine(current_mileage,
36 last_service_mileage)
37 battery = SpindlerBattery(last_service_date, current_date)
38 calliope = Car(engine, battery)
39 return calliope
41 def create_glissade(self, current_date: datetime,
42 last_service_date: datetime,
43 current_mileage: int, last_service_mileage: int) -> Car:
45 """Creates a Glissade car object.
47 Args:
48 current_date (datetime): The current date.
49 last_service_date (datetime): The date when the car was last serviced.
50 current_mileage (int): The current mileage of the car.
51 last_service_mileage (int): The mileage when the car was last serviced.
53 Returns:
54 Car: car object.
55 """
56 engine = WilloughbyEngine(current_mileage,
57 last_service_mileage)
58 battery = SpindlerBattery(last_service_date, current_date)
59 glissade = Car(engine, battery)
61 return glissade
63 def create_palindrome(self, current_date: datetime,
64 last_service_date: datetime,
65 warning_light_is_on: bool) -> Car:
66 """Creates a Palindrome car object.
68 Args:
69 current_date (datetime): The current date.
70 last_service_date (datetime): The date when the car was last serviced.
71 warning_light_is_on (bool): True if the warning light is on, False otherwise.
73 Returns:
74 Car: car object.
75 """
76 engine = SternmanEngine(warning_light_is_on)
77 battery = SpindlerBattery(last_service_date, current_date)
78 palindrome = Car(engine, battery)
80 return palindrome
82 def create_rorschach(self, current_date: datetime,
83 last_service_date: datetime,
84 current_mileage: int, last_service_mileage: int) -> Car:
86 """Creates a Rorschach car object.
88 Args:
89 current_date (datetime): The current date.
90 last_service_date (datetime): The date when the car was last serviced.
91 current_mileage (int): The current mileage of the car.
92 last_service_mileage (int): The mileage when the car was last serviced.
94 Returns:
95 Car: car object.
96 """
97 engine = WilloughbyEngine(current_mileage,
98 last_service_mileage)
99 battery = NubbinBattery(last_service_date,
100 current_date)
101 rorschach = Car(engine, battery)
102 return rorschach
104 def create_thovex(self, current_date: datetime,
105 last_service_date: datetime,
106 current_mileage: int, last_service_mileage: int) -> Car:
107 """Creates a Thovex car object.
109 Args:
110 current_date (datetime): The current date.
111 last_service_date (datetime): The date when the car was last serviced.
112 current_mileage (int): The current mileage of the car.
113 last_service_mileage (int): The mileage when the car was last serviced.
115 Returns:
116 Car: car object.
117 """
118 engine = CapuletEngine(current_mileage,
119 last_service_mileage)
120 battery = NubbinBattery(last_service_date, current_date)
122 thovex = Car(engine, battery)
124 return thovex