https://github.com/am-kantox/black_friday
Solution for internal Kantox test task (job applications) in Elixir
https://github.com/am-kantox/black_friday
Last synced: about 1 month ago
JSON representation
Solution for internal Kantox test task (job applications) in Elixir
- Host: GitHub
- URL: https://github.com/am-kantox/black_friday
- Owner: am-kantox
- Created: 2019-02-04T18:31:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-07T06:47:29.000Z (about 6 years ago)
- Last Synced: 2025-03-21T12:22:10.424Z (about 1 month ago)
- Language: Elixir
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BlackFriday
---
## Usage
```elixir
total =
with {:ok, order} = BlackFriday.Order.new() do
order
<<~ BlackFriday.Product.find("GR1")
<<~ "GR1"
<<~ "GR1"
~>> :checkout
endassert Money.new(:GBP, "6.22") == total
```---
## Task Description
You are the lead programmer for a small chain of supermarkets. You are required to make a simple
cashier function that adds products to a cart and displays the total price.#### You have the following test products registered:
| Product | code Name | Price |
| ------- | :----------: | :----: |
| GR1 | Green tea | £3.11 |
| SR1 | Strawberries | £5.00 |
| CF1 | Coffee | £11.23 |## Special conditions:
- The CEO is a big fan of buy-one-get-one-free offers and of green 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
- The CTO is a coffee addict. If you buy 3 or more coffees, the price of all coffees should drop
to two thirds of the original price.
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.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):```ruby
co = Checkout.new(pricing_rules)
co.scan(item)
co.scan(item)
price = co.total
```