/
geriot
/
calc
Обзор
Документация
Войти
/
geriot
/
calc
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Calculator.java
28 строк
827 B
geriot
upload files
09 май 2025, 15:20
09 май 2025, 15:20
f6f30b2
Код
Авторство
О чём код?
import java.util.function.*; public class Calculator { static Supplier<Calculator> instance = Calculator::new; public final BinaryOperator<Integer> plus = (x, y) -> x + y; public final BinaryOperator<Integer> minus = (x, y) -> x - y; public final BinaryOperator<Integer> multiply = (x, y) -> x * y; public final BinaryOperator<Integer> devide = (x, y) -> { if (y == 0) { throw new ArithmeticException("Деление на ноль невозможно"); } return x / y; }; public final UnaryOperator<Integer> pow = x -> x * x; public final UnaryOperator<Integer> abs = x -> (x > 0) ? x : -x; public final Predicate<Integer> isPositive = x -> x > 0; public final Consumer<Integer> println = System.out::println; }