Cleanup on isle 6

This commit is contained in:
2025-11-13 14:41:25 +01:00
parent 6a8173f184
commit a0f8a9187d
3 changed files with 32 additions and 50 deletions

View File

@@ -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, "");
}
}
}