Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 780 Bytes

File metadata and controls

15 lines (13 loc) · 780 Bytes

Lambda

  1. Given a list of Articles, Cart calculates the bill summing all the Prices;
  2. DiscountCart applies a 50% discount to all articles whose Price is greater than 5 CHF;
  3. With FreeDrinkCart all the drinks are for free;
  4. With PromotionCart all the articles whouse Price is smaller than 2 CHF are given for free;
  5. In DiscountCart, the discount and the threshold can be parametrized;
  6. Remove all the duplicated code, applying the Strategy Pattern;
  7. Replace theinterface and the 3 carts with a delegate and 3 methods;
  8. Replace the 3 methods with local functions;
  9. Replace local functions with a local delegate;
  10. Replace the delegate in the cart constructor with a Func;
  11. Simplify the syntax with a Lambda expression.