/
Arsalan
/
ABST
Обзор
Документация
Войти
/
Arsalan
/
ABST
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Account/CreditAccount.java
49 строк
1 KB
Arsalan
upload files
03 сен 2025, 16:22
03 сен 2025, 16:22
186399d
Код
Авторство
О чём код?
package Account; public class CreditAccount extends Account { long creditLimit; public CreditAccount(long balance) { super(balance); this.creditLimit = balance; } public boolean add(long amount) { if (amount > 0) { if (amount + balance > creditLimit) { balance = creditLimit; return true; } else { if (amount + balance <= creditLimit) { balance += amount; return true; } } } return false; } public boolean pay(long amount) { if (amount > 0) { if (amount <= balance) { balance -= amount; return true; } } return false; } public boolean transfer(Account account, long amount) { if (this.balance >= amount) { account.add(amount); this.pay(amount); return true; } return false; } @Override public void getBalance() { System.out.println("Ваш кредитный лимит составляет " + creditLimit + " рублей, " + "Задолженность составляет: " + (balance - creditLimit) + " рублей"); } }