/
Ersh
/
Homework
Обзор
Документация
Войти
/
Ersh
/
Homework
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/CreditAccount.java
32 строки
752 B
Ersh
upload files
05 авг 2025, 12:07
05 авг 2025, 12:07
8f9376d
Код
Авторство
О чём код?
public class CreditAccount extends Account { private final long creditLimit; public CreditAccount(long initialBalance, long creditLimit) { super(initialBalance); this.creditLimit = creditLimit; } @Override public boolean add(long amount) { if (amount <= 0) { return false; } if (balance + amount > 0) { return false; } balance += amount; return true; } @Override public boolean pay(long amount) { if (amount <= 0) { return false; } if (balance - amount < -creditLimit) { return false; } balance -= amount; return true; } }