Coverage for tire/carigan_tire.py: 100%

9 statements  

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

1"""Implements a subclass of the Tire class. 

2 

3The module contains the CariganTire class that inherits from the Tire class. 

4""" 

5 

6from tire.base_tire import Tire 

7from utils.input_validator import validate_array 

8 

9 

10class CariganTire(Tire): 

11 """Creates CariganTire tires. 

12 

13 Inherits from the Tire class. 

14 

15 methods: 

16 needs_serviced: Determines if the tire should be serviced. 

17 """ 

18 tire_wear_sensor = [] 

19 

20 def __init__(self, tire_wear_sensor: list): 

21 """Initializes CariganTire objects.""" 

22 # validate input 

23 tire_wear_sensor = validate_array(tire_wear_sensor, 'tire_wear_sensor') 

24 self.tire_wear_sensor = tire_wear_sensor 

25 

26 def needs_service(self) -> bool: 

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

28 

29 Returns: 

30 bool: True if one or more of the values in the 

31 tire wear sensor array is greater than or equal to 0.9 and 

32 False otherwise. 

33 

34 Usage: 

35 tire = CariganTire([0.5, 0.8, 0.9]) 

36 tire.needs_service() 

37 """ 

38 return any(i >= 0.9 for i in self.tire_wear_sensor)