From 5e9b4dd84d941aaa4daeef5602c49f633d138ece Mon Sep 17 00:00:00 2001 From: TMap Community <41735642+tmapcommunity@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:06:11 +0100 Subject: [PATCH 1/2] Update calculation_service.py Add function added --- src/service/calculation_service.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/service/calculation_service.py b/src/service/calculation_service.py index 4b3e905..0d6d3b3 100644 --- a/src/service/calculation_service.py +++ b/src/service/calculation_service.py @@ -1,7 +1,7 @@ """Module for the CalculationService class""" from tkinter import StringVar import divide_service as divide_service - +import add_service as add_service class CalculationService: """""Class for keeping track of, and evaluating calculations""""" @@ -29,10 +29,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(add_service.add(self.expression)) + else: + total = str(eval(self.expression)) if float(total) > 10: total = total + " <:o)" From 96280de2e7e2d621668cf2a76dfb3a7d10975545 Mon Sep 17 00:00:00 2001 From: TMap Community <41735642+tmapcommunity@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:17:23 +0100 Subject: [PATCH 2/2] add_service file added --- src/service/add_service.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/service/add_service.py diff --git a/src/service/add_service.py b/src/service/add_service.py new file mode 100644 index 0000000..0fb5708 --- /dev/null +++ b/src/service/add_service.py @@ -0,0 +1,6 @@ + + +def add(string): + arguments = string.split("+") + result = int(arguments[0]) + int(arguments[1]) + return result