wtorek, 26 lutego 2013

Code Kata: Vending Machine

Kata #1: Vending Machine

Your task is to implement a piece of software for a vending machine that sells sweets. The machine accepts coins and must be capable of returning change. It is up to you to decide on how inserted coins and change that is given out are represented. Consider the following variations of this exercise:
  • Simplification: you have an unlimited number of coins of every kind
  • Realistic: the machine is loaded with coins at the beginning and you have a limit on the number of coins of every kind
  • More realistic: the machine adds the inserted coins to respective coin slots and uses them to serve further transactions
  • Even more realistic: the machine tries to optimize the way of giving out coins - if there is danger of giving out too many coins of kind A, and there are is surplus of coins of kind B, then more of B coins are used to produce change
  • Futuristic: the machine asks you to provide it with coins that would help it return the proper change
How would your implementation of vending machine react if the amount of money inserted were less than the price of the chosen chocolate snack?

Brak komentarzy:

Prześlij komentarz