refactoring: Issue #2377: The repository code has been refactored to use the recor… (#2505)

* Issue #2377: The repository code has been refactored to use the record class

* Issue #2377: Refactored according to the rules defined for the repo code

* Issue #2377: Refactored according to the rules defined for the repo code

* Issue #2377: Refactored according to the rules defined for the repo code
This commit is contained in:
Mughees Qasim
2023-05-06 14:08:12 +05:00
committed by GitHub
parent c0e1603f90
commit 3ae6b07590
26 changed files with 244 additions and 293 deletions
@@ -27,26 +27,15 @@ package com.iluwatar.separatedinterface.invoice;
/**
* InvoiceGenerator class generates an invoice, accepting the product cost and calculating the total
* price payable inclusive tax (calculated by {@link TaxCalculator}).
*
*/
public class InvoiceGenerator {
/**
public record InvoiceGenerator(double amount, TaxCalculator taxCalculator) {
/** TaxCalculator description:
* The TaxCalculator interface to calculate the payable tax.
*/
private final TaxCalculator taxCalculator;
/**
* Amount description:
* The base product amount without tax.
*/
private final double amount;
public InvoiceGenerator(double amount, TaxCalculator taxCalculator) {
this.amount = amount;
this.taxCalculator = taxCalculator;
}
public double getAmountWithTax() {
return amount + taxCalculator.calculate(amount);
}
}
}