Coverage for com\automationpanda\example\calc_class.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-26 20:30 +0800

1""" 

2calc_class.py contains the Calculator class. 

3It uses the math functions from calc_func. 

4""" 

5 

6from com.automationpanda.example.calc_func import * 

7 

8 

9class Calculator(object): 

10 def __init__(self): 

11 self._last_answer = 0.0 

12 

13 @property 

14 def last_answer(self): 

15 return self._last_answer 

16 

17 def _do_math(self, a, b, func): 

18 self._last_answer = func(a, b) 

19 return self.last_answer 

20 

21 def add(self, a, b): 

22 return self._do_math(a, b, add) 

23 

24 def subtract(self, a, b): 

25 return self._do_math(a, b, subtract) 

26 

27 def multiply(self, a, b): 

28 return self._do_math(a, b, multiply) 

29 

30 def divide(self, a, b): 

31 return self._do_math(a, b, divide) 

32 

33 def maximum(self, a, b): 

34 return self._do_math(a, b, maximum) 

35 

36 def minimum(self, a, b): 

37 return self._do_math(a, b, minimum)