-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgistfile1.txt
54 lines (36 loc) · 1.45 KB
/
gistfile1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Our request for global domination has prompted us to open a supermarket - we
sell only three products:
Product code | Name | Price
-----------------------------------------
FR1 | Fruit tea | £3.11
SR1 | Strawberries | £5.00
CF1 | Coffee | £11.23
Our CEO is a big fan of buy-one-get-one-free offers and of fruit tea. He wants
us to add a rule to do this.
The COO, though, likes low prices and wants people buying strawberries to get a
price discount for bulk purchases. If you buy 3 or more strawberries, the price
should drop to £4.50
Our check-out can scan items in any order, and because the CEO and COO change
their minds often, it needs to be flexible regarding our pricing rules.
The interface to our checkout looks like this (shown in Ruby):
co = Checkout.new(pricing_rules)
co.scan(item)
co.scan(item)
price = co.total
Implement a checkout system that fulfils these requirements.
Bonus features
--------------
What about configurable discounts?
Global rules (that apply to the whole basket).
Contrasting rules: what to do?
Should one product only be allowed to participate into one rule and only one?
What about rules that are referred to multiple product types? Does this affect
how we pass the rules? For example the "meal deal".
Test data
---------
Basket: FR1,SR1,FR1,FR1,CF1
Total price expected: £22.45
Basket: FR1,FR1
Total price expected: £3.11
Basket: SR1,SR1,FR1,SR1
Total price expected: £16.61