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!
Pass in a list of purchased items that produces a total bill.
e.g. [“Cola”, “Coffee”, “Cheese Sandwich”] returns 3.5
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
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.