Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package com.gof.behavioral.chainofresponsibility.handler;
  2.  
  3. import com.gof.behavioral.chainofresponsibility.request.ShoppingCart;
  4. import org.javamoney.moneta.Money;
  5.  
  6. import javax.money.MonetaryAmount;
  7.  
  8. /**
  9. * The type First purchase.
  10. */
  11. public class FirstPurchase extends Discount {
  12.  
  13. /**
  14. * Instantiates a new First purchase.
  15. *
  16. * @param successor the successor
  17. * @param shoppingCart the shopping cart
  18. */
  19. public FirstPurchase(Discount successor, ShoppingCart shoppingCart) {
  20. super(successor, shoppingCart);
  21. }
  22.  
  23. @Override
  24. public MonetaryAmount handleRequest() {
  25. // in a real scenario, this condition should be verified.
  26. // in this example, for each call, we'll apply 10 Euro for the first purchase
  27. return Money.of(10, CURRENCY_CODE).add(next());
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement