Exemplo n.º 1
0
  @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;
  }
Exemplo n.º 2
0
  public boolean isDiscounted(OrderLine orderLine) {
    if (orderLine.getProductQuantity() >= requiredQuantity) return super.isDiscounted(orderLine);

    return false;
  }