/
itokar98
/
HomeWorkABST
Обзор
Документация
Войти
/
itokar98
/
HomeWorkABST
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/CreditAccount.java
35 строк
825 B
Ilya Tokar
first_commit
09 июл 2025, 14:26
09 июл 2025, 14:26
25e2603
Код
Авторство
О чём код?
public class CreditAccount extends Account { private long creditLimit; public CreditAccount(long initialBalance, long creditLimit) { super(initialBalance); 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; } @Override public boolean transfer(Account account, long amount) { if (pay(amount)) { account.add(amount); return true; } return false; } }