We need to model a shopping cart for a corner shop. The cart should keep track of the list of items added, and correctly calculate the price.
Items are added to the basket using stock-keeping unit (SKU) codes. The items in the shop are:
Name | Price | SKU |
---|---|---|
Potatoes | 10.00 | STAPOT |
Rice | 30.00 | STARIC |
Coffee | 14.99 | STACOF |
Newspaper | 2.99 | MEDNEW |
The shopping cart should allow these operations to be performed:
An alternative version or extension of the story uses discount coupons that can be added to the shopping cart.
In order to keep customers happy, the corner shop has added discount coupons. This means that, in order to support these discounts, our shopping cart needs to be able to read and apply discount coupons to the current items. The supported coupons are:
Type | SKU | Rule |
---|---|---|
Fixed price discount | FIX_TEN | Discounts 10.00 off the total amount of the cart |
Product discount | HALF_STAPOT | Reduces all STAPOT items to half price |
The shopping cart should have a new scan coupon
operation which takes a SKU and adds it to the cart. Please bear in mind that the total_amount
must not be a negative number, the minimum value for the total_amount
is 0.