From 75375fe67a9985934bd7896b75171bdfde06f467 Mon Sep 17 00:00:00 2001 From: TMap Community <41735642+tmapcommunity@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:22:11 +0100 Subject: [PATCH 1/2] Subtract_feature file added --- src/service/subtract_service.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/service/subtract_service.py diff --git a/src/service/subtract_service.py b/src/service/subtract_service.py new file mode 100644 index 0000000..7fd90f0 --- /dev/null +++ b/src/service/subtract_service.py @@ -0,0 +1,6 @@ + + +def add(string): + arguments = string.split("-") + result = int(arguments[0]) - int(arguments[1]) + return result From 6cef9e0ba0c1acd83730ae0ea64747a0837e6164 Mon Sep 17 00:00:00 2001 From: TMap Community <41735642+tmapcommunity@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:25:11 +0100 Subject: [PATCH 2/2] Update calculation_service.py --- src/service/calculation_service.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/service/calculation_service.py b/src/service/calculation_service.py index 4b3e905..bf9c07c 100644 --- a/src/service/calculation_service.py +++ b/src/service/calculation_service.py @@ -1,6 +1,7 @@ """Module for the CalculationService class""" from tkinter import StringVar import divide_service as divide_service +import subtract_service as subtract_service class CalculationService: @@ -29,10 +30,12 @@ def equalpress(self): try: # evaluate the expression/calculation - if "/" not in self.expression: - total = str(eval(self.expression)) - else: + if "/" in self.expression: total = str(divide_service.divide(self.expression)) + if "-" in self.expression: + total = str(subtract_service.subtract(self.expression)) + else: + total = str(eval(self.expression)) if float(total) > 10: total = total + " <:o)"