/
FreeZZZeee
/
the_ninth_task
Обзор
Документация
Войти
/
FreeZZZeee
/
the_ninth_task
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Account.java
37 строк
829 B
ЛЕОНИД ВИТАЛЬЕВИЧ ЯКОВЛЕВ
first_commit
09 фев 2026, 11:25
09 фев 2026, 11:25
54a9e8f
Код
Авторство
О чём код?
abstract class Account { protected long balance; protected abstract boolean canPay(long amount); protected abstract boolean canAdd(long amount); public boolean add(long amount) { if (amount <= 0 || !canAdd(amount)) { return false; } balance += amount; return true; } public boolean pay(long amount) { if (amount <= 0 || !canPay(amount)) { return false; } balance -= amount; return true; } public boolean transfer(Account account, long amount) { if (amount <= 0 || account == null) { return false; } if (pay(amount) && account.add(amount)) { return true; } return false; } public long getBalance() { return balance; } }