Coverage for tire/octo_prime_tire.py: 100%

9 statements  

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

1"""This module defines a specilised Tire named Octo Prime Tire.""" 

2 

3from tire.base_tire import Tire 

4from utils.input_validator import validate_array 

5 

6 

7class OctoprimeTire(Tire): 

8 """Creates OctoprimeTire instances. 

9 Inherits from the Tire class. 

10 

11 methods: 

12 needs_serviced: Determines if the tire should be serviced. 

13 """ 

14 tire_wear_sensor = [] 

15 

16 def __init__(self, tire_wear_sensor: list): 

17 """Initializes OctoprimeTire objects.""" 

18 # validate input 

19 tire_wear_sensor = validate_array(tire_wear_sensor, 'tire_wear_sensor') 

20 self.tire_wear_sensor = tire_wear_sensor 

21 

22 def needs_service(self) -> bool: 

23 """Determines if the OctoprimeTire should be serviced. 

24 

25 Returns: 

26 bool: True when the sum of all values in the tire wear 

27 array is greater than or equal to 3 

28 

29 Usage: 

30 tire = OctoprimeTire([0.5, 0.8, 0.9]) 

31 tire.needs_service() 

32 """ 

33 return sum(self.tire_wear_sensor) >= 3