Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/service/calculation_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module for the CalculationService class"""
from tkinter import StringVar
import divide_service as divide_service
import multiply_service as multiply_service


class CalculationService:
Expand Down Expand Up @@ -29,10 +30,13 @@ 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(multiply_service.multiply(self.expression))
else:
total = str(eval(self.expression))


if float(total) > 10:
total = total + " <:o)"
Expand Down
4 changes: 4 additions & 0 deletions src/service/multiply_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def multiply(string):
arguments = string.split("*")
result = int(arguments[0]) * int(arguments[1])
return result