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
9 changes: 6 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 subtract_service as subtract_service


class CalculationService:
Expand Down Expand Up @@ -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)"
Expand Down
6 changes: 6 additions & 0 deletions src/service/subtract_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


def add(string):
arguments = string.split("-")
result = int(arguments[0]) - int(arguments[1])
return result