Implement a Supermarket checkout that calculates the total price of a number of items.
Some items have multiple prices based on price rules such as:
- buy 3 (equals) items and pay for 2
- buy 2 (equals) items for a special price
- buy 3 (in a set of items) and the cheapest is free
- for each N (equals) items X, you get K items Y for free
The output required is the receipt with the actual price of every item and the grand total.
You should not spend more than a few hours on this problem.
You may choose any means of accepting input and producing output, including the use of a test harness.
The code should be simple and flexible so that any new rule should be added with the minimum effort.
- Java 8
- Maven 3