/
2007chester
/
ProjectsNetology
Обзор
Документация
Войти
/
2007chester
/
ProjectsNetology
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CreditAccount.java
28 строк
630 B
2007chester
HW_ABST
06 фев 2025, 17:50
06 фев 2025, 17:50
efe85c0
Код
Авторство
О чём код?
public class CreditAccount extends Account { private final long creditLimit; public CreditAccount(long creditLimit) { super(0); this.creditLimit = -creditLimit; } @Override public boolean add(long amount) { if (amount > 0 && balance + amount <= 0) { balance += amount; return true; } return false; } @Override public boolean pay(long amount) { if (amount > 0 && balance - amount >= creditLimit) { balance -= amount; return true; } return false; } }