Skip to content

rubberduck203/VendingMachineKata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VendingMachineKata

My implementation of Guy Royse's Vending Machine Kata.

Design

Vending machines are really just Finite State Machines and can be implemented in hardware. If the wikipedia article above is a bit too heavy, there's a great video from Computerphile, Computers without memory.

Being we're building a state machine, I suspect we'll make use of the state pattern.

The following display states exist:

  1. No Money (Insert Coin/Exact Change)
  2. Money (Current Value)
  3. Display Price
  4. Display Thank you!
  5. Sold Out

state diagram

Future Improvements

  • The change making algorithm does find opitmal results, but the Exact Change Only algorithm does not.
  • I don't care for the fact that the abstract base VendingMachineState class has knowledge of its inheritors.
    • It was implemented this way to centralize logic that would have otherwise had to have been implemented in each of the child classes.
    • Find a way to decouple it.
  • There are several missing states. A few of the states have if...then logic that should really be represented as different states unto themselves.

Build

Nothing special here. Just compile and run the tests.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages