Skip to content
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
4 changes: 4 additions & 0 deletions multiply_service.py
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comment on function of code

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def multiply(string):
arguments = string.split("*")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

result = int(arguments[0]) * int(arguments[1])
return result

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no blank line at the end of the file

77 changes: 73 additions & 4 deletions src/calculator_application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,75 @@
"""This module starts the application."""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we going to start the calculator now?

import calculator_view as calculator_view
"""Module for the CalculationService class"""
from tkinter import StringVar
import divide_service as divide_service

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

divide_service does not exist in this repository

import multiply_service as multiply_service


if __name__ == "__main__":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the program now does nothing on execution

calculator_view.initialize_calculator()
class CalculationService:
"""""Class for keeping track of, and evaluating calculations"""""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less quotes maybe?


# Constructor for the class
# Initializes a String expression and a StringVar equation
# StringVar is used because it is required for the tkinter text box
def __init__(self):
print("initialized")
self.expression = ""
self.equation = StringVar()

def press(self, num):
"""Function to update the expression in the text entry box"""
# appends the new number to the existing expression
self.expression = self.expression + str(num)

# update the expression by using set method
self.equation.set(self.expression)

def equalpress(self):
"""Function to evaluate the final expression"""

# using a try/except in order to catch errors
try:

# evaluate the expression/calculation
if "/" in self.expression:
total = str(divide_service.divide(self.expression))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

divide_service does not exist in this repository

if "*" in self.expression:
total = str(multiply_service.multiply(self.expression))
else:
total = str(eval(self.expression))


if float(total) > 10:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not according to Py style guide: "distinguish arguments from the rest"

total = total + " <:o)"

self.equation.set(total)

# reset the expression to the empty string
self.expression = ""

# show error on the screen after an exception is caught
except:
self.equation.set(" error ")
self.expression = ""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary amount of newlines



def clear(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the code from line 56 onwards not commented intentionally?

"""Function to clear the contents of text entry box"""
self.expression = ""
self.equation.set("")

def get_expression(self):
"""get expression"""
return self.expression

def set_expression(self, newExpression):
"""set expression"""
self.expression = newExpression

def get_equation(self):
"""get equation"""
return self.equation

def set_equation(self, new_equation):
"""set equation"""
self.equation.set(new_equation)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no blank line at the end of the file