Coverage for engine/capulet_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 CapuletEngine. 

2""" 

3from engine.base_engine import Engine 

4from utils.input_validator import validate_int 

5 

6 

7class CapuletEngine(Engine): 

8 """Creates CapuletEngine 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 CapuletEngine objects.""" 

18 # validate input 

19 current_mileage = validate_int(current_mileage, 'current_mileage') 

20 last_service_mileage = validate_int(last_service_mileage, 'last_service_mileage') 

21 self.current_mileage = current_mileage 

22 self.last_service_mileage = last_service_mileage 

23 

24 def needs_service(self): 

25 """Determines if the engine should be serviced 

26 

27 Returns: 

28 bool: True if the engine should be serviced, False otherwise. 

29 """ 

30 return self.current_mileage - self.last_service_mileage > 30000