Answer the question
In order to leave comments, you need to log in
Create multiple accounts and calculate taxes for them?
There is a class Bill , in which the field TaxType taxType is added; and the payTaxes() method :
public class Bill {
private double amount;
private TaxType taxType;
private TaxService taxService;
public Bill(double amount, TaxType taxType, TaxService taxService){
this.amount = amount;
this.taxType = taxType;
this.taxService = taxService;
}
public void payTaxes(){
//TODO вместо 0.0 посчитать размер налога исходя из TaxType
double taxAmount = 0.0;
taxService.payOut(taxAmount);
}
}
public class TaxService {
public void payOut(double taxAmount){
System.out.format("Уплачен налог в размере %.2f%n", taxAmount);
}
}
public class TaxType {
public double calculateTaxFor(double amount){
//TODO override me!
return 0.0;
}
}
public class BillMain {
public static void main(String[] args) {
TaxService taxService = new TaxService();
TaxType taxType = new TaxType();
Bill[] payments = new Bill[]{
//TODO создать платежи с различными типами налогооблажения
};
for (int i = 0; i < payments.length; i++) {
Bill bill = payments[i];
bill.payTaxes();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question