Skip to content

Commit

Permalink
feat: add logarithm buttom and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Apr 4, 2024
1 parent 6f1ae20 commit 96456e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions calculator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def square_root(self):

def power(self):
self._append("**")

def logarithm(self):
self._append("log")

def compute_result(self) -> Number:
try:
Expand Down
4 changes: 4 additions & 0 deletions calculator/ui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
['1', '2', '3', '-'],
['.', '0', '=', '+'],
['(', '√', '**', ')'],
['log'],
]


Expand Down Expand Up @@ -77,6 +78,9 @@ def on_button_press(self, button):
self._calc.open_parenthesis()
case "**":
self._calc.power()
case "log":
self._calc.logarithm()
self._calc.open_parenthesis()
case _:
self._calc.digit(button.text)
self.display.text = self._calc.expression or "0"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "unibo-dtm-se-calculator"
packages = [
{ include = "calculator" },
]
version = "0.1.2"
version = "0.2.0"
description = "A simple calculator toolkit written in Python, with several UIs. It is part of the Software Engineering course at the University of Bologna."
authors = ["Giovanni Ciatto <[email protected]>"]
license = "Apache 2.0"
Expand Down

0 comments on commit 96456e6

Please sign in to comment.