Skip to content

eprusakov/cash_register

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Prerequisites

The setup steps expect following tools installed on the system.

  • Github
  • Ruby "3.0.0"
  • Rails "7.0.8.1"
1. Check out the repository
git clone git@github.com:eprusakov/cash_register.git
2. Install gems
bundle install
3. Start the Rails console

You can start the rails console using the command given below.

bundle exec rails c

And now you can use application inside the rails console

Usage

1. Create rules' set from available rules
pricing_rules = [Rules::GreenTeaDiscount.new, Rules::StrawberryDiscount.new, Rules::CoffeeDiscount.new]
Available rules
  1. Rule makes each 2nd green tea free to buy

Rules::GreenTeaDiscount

  1. Rule makes each strawberry to cost 4.50 if there are 3 or more strawberiies in a cart

Rules::StrawberryDiscount

  1. Rule drops all coffee prices to 2/3 from the initial cost if there 3 or more coffees in a cart

Rules::CoffeeDiscount

2. Create products' preset using any values you want, but keep keys
green_tea = Product.new(code: "GT1", name: "Green Tea", price: 3.11)
Available product's with discount
  1. Green tea

Product.new(code: "GT1", name: "Green Tea", price: 3.11)

  1. Strawberry

Product.new(code: "SB1", name: "Strawberry", price: 5.00)

  1. Coffee

Product.new(code: "CF1", name: "Coffee", price: 11.23)

3. Create cart's instance
checkout = Checkout.new(pricing_rules)
4. Scan any amount of products
checkout.scan(green_tea)
checkout.scan(*smth_other*)
5. Check all cart items with quantity
checkout.cart
6. Check total price of current cart
checkout.total

About

Test repo for tech challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages