Giter VIP home page Giter VIP logo

checkout-process-review's Introduction

Checkout

Implement a supermarket checkout that calculates the total price of a number of items

  • to be run in a REPL like IRB. Don't worry about I/O.
  • (actually run in the browser console)

Requirements

In a normal supermarket, things are identified using Stock Keeping Units, or SKUs. In our store, we'll use individual letters of the alphabet (A, B, C, and so on). Our goods are priced individually. In addition, some items are multi-priced: buy n of them, and they'll cost you y pounds.

For example, item A might cost 50 pounds individually, but this week we have a special offer:

buy three As and they'll cost you 130. Our price table and offers:

+------+-------+----------------+
| Item | Price | Special offers |
+------+-------+----------------+
| A    | 50    | 3A for 130     |
| B    | 30    | 2B for 45      |
| C    | 20    |                |
| D    | 15    |                |
+------+-------+----------------+

Notes:

For any illegal input (non capitals) simply return -1 In order to complete the round you need to implement the following method: checkout(String) -> Integer

Where:

param[0] = eg. 'AAB', a String containing the SKUs of all the products in the basket @return = eg. 120, an Integer representing the total checkout value of the items


Acceptance Criteria

  1. shop.checkout('aBc') # => -1
  2. shop.checkout('-B8x') # => -1
  3. shop.checkout(18) # => -1
  4. shop.checkout('AA') # => 100
  5. shop.checkout('ABCD') # => 115
  6. shop.checkout('AAA') # => 130
  7. shop.checkout('AAAAAA') # => 260

Breakdown

  1. shop = new Shop

  2. checkout() function takes a string of chars, each representing a SKU

  3. checkout for a single, simple item (no discount)

  4. checkout for 2 simple items (no discount)

  5. checkout multiple items (no discount)


Got to starting this next one but not finishing in 30 mins


  1. checkout 3 A's with discount

Finished first test on the discounted A's acceptance criteria after another 5-10 mins


Reflection

  • Completed ACs 4 and 5 (in 30 minute process review window)

  • Completed AC 6 10 mins after time (40 mins)

  • Link to screen recording here

Improvements

  1. Focus on the ACs that need to be met when breaking things down
  2. Next small step to pass next easy test, still making some bigger jumps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.