@Override public long apply(OrderLine orderLine) { // Compare Discount.productID with orderLine.productID // If true return reduced price otherwise return normal price int productAmount = orderLine.getProductQuantity(); long productPrice = orderLine.getProductPrice(); if (itemIDs.contains(orderLine.getProductID())) productAmount -= (productAmount / requiredQuantity) * reductionQuantity; return productAmount * productPrice; }
public boolean isDiscounted(OrderLine orderLine) { if (orderLine.getProductQuantity() >= requiredQuantity) return super.isDiscounted(orderLine); return false; }