From 96456e6eb6465c8e2347f38e2c13e670699e23a9 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Thu, 4 Apr 2024 12:52:53 +0200 Subject: [PATCH] feat: add logarithm buttom and functionality --- calculator/__init__.py | 3 +++ calculator/ui/gui.py | 4 ++++ pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/calculator/__init__.py b/calculator/__init__.py index df9cb72..59b3cca 100644 --- a/calculator/__init__.py +++ b/calculator/__init__.py @@ -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: diff --git a/calculator/ui/gui.py b/calculator/ui/gui.py index 7640200..ed4e3a9 100644 --- a/calculator/ui/gui.py +++ b/calculator/ui/gui.py @@ -11,6 +11,7 @@ ['1', '2', '3', '-'], ['.', '0', '=', '+'], ['(', '√', '**', ')'], + ['log'], ] @@ -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" diff --git a/pyproject.toml b/pyproject.toml index c287970..49ba55f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "Apache 2.0"