Я хочу написать калькулятор с solid. У меня нету нарушений по поводу solid? Калькулятор…
- User
Я хочу написать калькулятор с solid. У меня нету нарушений по поводу solid?
Калькулятор SOLID
Импорты
import abc import os
Переменные
MENU = """Калькулятор!
-
Сложение [+]
-
Вычитание [-]
-
Умножение [*]
-
Деление [/]
-
Нахождение процента от числа [%]
-
История вычислений
-
Выход """
Основной код программы
class BaseOperation(abc.ABC): def init(self, num_one: int | float, num_two: int | float) -> None: self._num_one = num_one self._num_two = num_two
def math_operation(self) -> int | float: pass+
class Addition(BaseOperation): def init(self, num_one: int | float, num_two: int | float) -> None: super().init(num_one, num_two)
def math_operation(self) -> int | float: return self._num_one + self._num_two-
class Subtraction(BaseOperation): def init(self, num_one: int | float, num_two: int | float) -> None: super().init(num_one, num_two)
def math_operation(self) -> int | float: return self._num_one - self._num_two*
class Multiplication(BaseOperation): def init(self, num_one: int | float, num_two: int | float) -> None: super().init(num_one, num_two)
def math_operation(self) -> int | float: return self._num_one * self._num_two/
class Division(BaseOperation): def init(self, num_one: int | float, num_two: int | float) -> None: super().init(num_one, num_two)
def math_operation(self) -> int | float: return self._num_one / self._num_two%
class PercentageCalculator(BaseOperation): def init(self, num_one: int | float, num_two: int | float) -> None: super().init(num_one, num_two)
def math_operation(self) -> int | float: return (self._num_one / self._num_two) * 100def clear_console(): os.system("cls")
def Calculator(user_choice_operation, num_one, num_two) -> str | int | float: if user_choice_operation == "1": addition = Addition(num_one, num_two).math_operation() return addition
elif user_choice_operation == "2": pass elif user_choice_operation == "3": pass elif user_choice_operation == "4": pass elif user_choice_operation == "5": pass elif user_choice_operation == "6": pass -
- Assistant