Giter Site home page Giter Site logo

cafex's Introduction

Scenario

Cafe X menu consists of the following items:

  • Cola - Cold - 50p
  • Coffee - Hot - £1.00
  • Cheese Sandwich - Cold - £2.00
  • Steak Sandwich - Hot - £4.50

Customers don’t know how much to tip and staff need tips to survive!

Step 1 : Standard Bill

Pass in a list of purchased items that produces a total bill.

e.g. [“Cola”, “Coffee”, “Cheese Sandwich”] returns 3.5

Step 2: Service Charge

Add support for a service charge :

  • When all purchased items are drinks no service charge is applied
  • When purchased items include any food apply a service charge of 10% to the total bill (rounded to 2 decimal places)
  • When purchased items include any hot food apply a service charge of 20% to the total bill with a maximum £20 service charge

Assumptions

The data type of the the food price is selected as BigDecimal as opposed to using a DomainObject such as Money. This is because BigDecimal is better in rounding (https://alvinalexander.com/scala/scala-money-currency-bigdecimal-class-libraries) The code ignores the non-available menu items and continues processing.

cafex's People

Watchers

James Cloos avatar  avatar

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.