Skip to content
Snippets Groups Projects
Commit 7f83d31e authored by Martin Roberto Castillo Hund's avatar Martin Roberto Castillo Hund
Browse files

app: don't show status in tests, handle /0 better, calculate() return result

parent c84e94b5
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@ class Rechner:
self.lastchar = ''
def show_status(self):
if __name__ != "__main__":
return
print("zahlen:", self.zahlen)
print("operatoren:", self.operatoren)
print("letztes zeichen:", self.lastchar)
......@@ -65,9 +67,21 @@ class Rechner:
zahlen.append(linkeZahl * rechteZahl)
elif op == "/":
#XXX durch 0?
zahlen.append(linkeZahl / rechteZahl)
try:
zahlen.append(linkeZahl / rechteZahl)
except ZeroDivisionError:
# stacks leeren?
zahlen.clear()
operatoren.clear()
return "DIVZERO"
else:
print("Unerwarteter Operator in Rechner.calculate():", op)
return "Unbekanntes Zeichen: " + op
# assert not operatoren
# assert len(zahlen) == 1
return zahlen.pop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment