/
maksh
/
hw8
Обзор
Документация
Войти
/
maksh
/
hw8
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Company.java
46 строк
1 KB
maksh
upload files
08 июн 2025, 22:39
08 июн 2025, 22:39
513ab73
Код
Авторство
О чём код?
import deal.*; import taxes.*; public class Company { private String title; private int debit; private int credit; private TaxSystem taxSystem; public Company(String title, TaxSystem taxSystem) { this.title = title; this.taxSystem = taxSystem; this.credit = 0; this.debit = 0; } public void shiftMoney(int amount) { if (amount > 0) { debit += amount; } else if (amount < 0) { credit += Math.abs(amount); } } public void setTaxSystem(TaxSystem taxSystem) { this.taxSystem = taxSystem; } public void payTaxes() { int resultTax = taxSystem.calcTaxFor(debit, credit); System.out.println("Компания " + title + " уплатила налог в размере: " + resultTax + " руб."); debit = 0; credit = 0; } public int applyDeals(Deal[] deals) { for(Deal deal: deals) { credit += deal.getCreditChange(); debit += deal.getDebitChange(); System.out.println( deal.getComment()); } int resultDebitAndCredit = debit - credit; payTaxes(); return resultDebitAndCredit; } }