Cleanup on isle 6
This commit is contained in:
@@ -14,30 +14,6 @@ import static inventory.ProductFactory.BOOK_TYPE;
|
||||
*/
|
||||
public class DiscountCalculator {
|
||||
|
||||
/**
|
||||
* Inner class to hold discount calculation results.
|
||||
*/
|
||||
public static class DiscountResult {
|
||||
private final double discountAmount;
|
||||
private final String description;
|
||||
|
||||
public DiscountResult(double discountAmount, String description) {
|
||||
if (discountAmount < 0) {
|
||||
throw new IllegalArgumentException("Discount amount must be greater than 0");
|
||||
}
|
||||
this.discountAmount = discountAmount;
|
||||
this.description = Objects.requireNonNullElse(description, "");
|
||||
}
|
||||
|
||||
public double getDiscountAmount() {
|
||||
return discountAmount;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param product - the product being purchased
|
||||
* @param quantity - quantity being purchased
|
||||
@@ -90,4 +66,14 @@ public class DiscountCalculator {
|
||||
private static boolean isEligibleForBulkDiscount(int quantity) {
|
||||
return quantity >= 5;
|
||||
}
|
||||
|
||||
public record DiscountResult(double discountAmount, String description) {
|
||||
public DiscountResult(double discountAmount, String description) {
|
||||
if (discountAmount < 0) {
|
||||
throw new IllegalArgumentException("Discount amount must be greater than 0");
|
||||
}
|
||||
this.discountAmount = discountAmount;
|
||||
this.description = Objects.requireNonNullElse(description, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user