/
1091950
/
Task8
Обзор
Документация
Войти
/
1091950
/
Task8
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CreditAccount.java
36 строк
799 B
1091950
upload files
07 дек 2025, 01:01
07 дек 2025, 01:01
2bade73
Код
Авторство
О чём код?
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) { return false; } long newBalance = balance + amount; if (newBalance > 0) { return false; } balance = newBalance; return true; } @Override public boolean pay(long amount) { if (amount <= 0) { return false; } long newBalance = balance - amount; if (newBalance < -creditLimit) { return false; } balance = newBalance; return true; } }