Coverage for engine/willoughby_engine.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-03-09 21:08 +0000

1"""This module defines a specilised engine named WilloughbyEngine. 

2""" 

3from engine.base_engine import Engine 

4from utils.input_validator import validate_int 

5 

6 

7class WilloughbyEngine(Engine): 

8 """Creates WilloughbyEngine objects. 

9 

10 Inherits from the Engine class. 

11 

12 methods: 

13 needs_serviced: Determines if the engine should be serviced. 

14 """ 

15 def __init__(self, current_mileage: int, 

16 last_service_mileage: int): 

17 """Initializes WilloughbyEngine objects.""" 

18 

19 # validate input 

20 current_mileage = validate_int(current_mileage, 'current_mileage') 

21 last_service_mileage = validate_int(last_service_mileage, 'last_service_mileage') 

22 

23 self.current_mileage = current_mileage 

24 self.last_service_mileage = last_service_mileage 

25 

26 def needs_service(self): 

27 """Determines if the WilloughbyEngine should be serviced. 

28 

29 Returns: 

30 bool: True if the last service mileage exceeds 60000, False otherwise. 

31 """ 

32 return self.current_mileage - self.last_service_mileage > 60000