Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Add feature #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions src/service/add_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
10 changes: 6 additions & 4 deletions src/service/calculation_service.py
Original file line number Diff line number Diff line change
@@ -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"""""
Expand Down Expand Up @@ -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)"
Expand Down