Skip to content

pszymczyk/vending-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vending-machine SPOCK kata


  1. clone vending-machine project

    git clone https://[email protected]/pawelszymczyk/vending-machine.git

  2. Checkout proper branch (team01..10)
  3. If you use IntelliJ, run gradle idea or simply import Gradle project
  4. Start playing with tests:

    gradle test

    gradle cleanTest test - to run again when nothing changed (gradle works incrementally)

  5. Kata - implement 4 user stories

User stories

Based on https://github.com/guyroyse/vending-machine-kata


1. Accept Coins

As a vendor
I want a vending machine that accepts coins
So that I can collect money from the customer

The vending machine will accept valid coins (nickels, dimes, and quarters) and reject invalid one (pennies). When a valid coin is inserted the amount of the coin will be added to the current amount and the display will be updated. When there are no coins inserted, the machine displays INSERT COIN. Rejected coins are placed in the coin return.

NOTE: The temptation here will be to create Coin objects that know their value. However, this is not how a real vending machine works. Instead, it identifies coins by their weight and size and then assigned a value to what was inserted. You will need to do something similar. This can be simulated using strings, constants, enums, symbols, or something of that nature.


2. Select Product

As a vendor
I want customers to select products
So that I can give them an incentive to put money in the machine

There are three products: cola for $1.00, chips for $0.50, and candy for $0.65. When the respective button is pressed and enough money has been inserted, the product is dispensed and the machine displays THANK YOU. If the display is checked again, it will display INSERT COINS and the current amount will be set to $0.00. If there is not enough money inserted then the machine displays PRICE and the price of the item and subsequent checks of the display will display either INSERT COINS or the current amount as appropriate.


3. Make Change

As a vendor
I want customers to receive correct change
So that they will use the vending machine again

When a product is selected that costs less than the amount of money in the machine, then the remaining amount is placed in the coin return.


4. Storage & eMails

As a venodr
I want to be notified via email when machine runs out of product

Vending machine has one shelve per product, each with 10 items capacity. Full machine contains 10x cola, 10x chips and 10x candy.

Each time when user selects sold out product machine should do two things:

  1. display NO ${productName}, SORRY
  2. send email to vendor with supply request

See

  1. https://williamdurand.fr/2013/06/03/object-calisthenics/
  2. https://docs.spockframework.org
  3. https://github.com/pcierpiatka/groovy_workshop
  4. https://groovy.codehaus.org/Groovy+style+and+language+feature+guidelines+for+Java+developers

Schedule

Slot            Co                          
9:00 -  9:30    Spock Intro                 
9:40 -  11:00   Story 1 accept coins        
11:10 - 12:30   Story 2 select product      
12:30 - 13:30   Przerwa
13:30 - 14:50   Story 3 make change         
15:00 - 16:30   Story 4 storage and emails 

About

vending-machine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published