/
v.nilov
/
Zadanie9
Обзор
Документация
Войти
/
v.nilov
/
Zadanie9
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CreditAccount.java
30 строк
722 B
v.nilov
Zadanie9
17 ноя 2025, 23:30
17 ноя 2025, 23:30
914b755
Код
Авторство
О чём код?
public class CreditAccount extends Account { private final long creditLimit; public CreditAccount(long balance, long creditLimit) { super(balance); 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; } public long getCreditLimit() { return creditLimit; } }