The Specification
Although it’d be great to have a well-defined specification, we’ll work from a more realistic starting point by keeping things vague. We’ll write a system that’s given a bunch of items that have been scanned. We have to look up the price of these items and calculate the total amount to charge. A fun bit to add is that some items in groups give an instant rebate: you may get two articles for the price of one, or specific amounts like five bags of chips for $7.
In fact, the code kata gives the following table:
Item | Unit Price | Special Price |
|---|---|---|
A | 50 | 3 for 130 |
B | 30 | 2 for 45 |
C | 20 | |
D | 15 |
The checkout function should accept items in any order, so ["B","A","B"] would give the 2-for-45 rebate for the Bs being bought. The only call that needs to be exposed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access