/
shuchkin
/
NETOLOGY-HW_POLY
Обзор
Документация
Войти
/
shuchkin
/
NETOLOGY-HW_POLY
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Company.java
61 строка
1 KB
Sergey Shuchkin
0.3
01 дек 2025, 18:17
01 дек 2025, 18:17
2e1f331
Код
Авторство
О чём код?
import taxes.TaxSystem; public class Company { private final String title; private int debit; private int credit; private TaxSystem taxsystem; public Company(String title) { this.title = title; this.debit = 0; this.credit = 0; } public String getTitle() { return title; } public void shiftMoney(int amount) { if (amount > 0) { this.debit += amount; } else if (amount < 0) { this.credit += Math.abs(amount); } } public int getDebit() { return debit; } public int getCredit() { return credit; } public int getBalance() { return debit - credit; } public void setTaxSystem(TaxSystem taxsystem) { this.taxsystem = taxsystem; } public void payTaxes() { int tax = this.taxsystem.calcTaxFor(this.debit, this.credit); System.out.printf("Компания %s уплатила налог в размере: %d руб.%n", this.title, tax); this.debit = 0; this.credit = 0; } public int applyDeals(Deal[] deals) { for (Deal deal : deals) { System.out.println(deal.getComment()); this.debit += deal.getDebitChange(); this.credit += deal.getCreditChange(); } int result = debit - credit; this.payTaxes(); return result; } }