Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnknownCoin states that a given coin is unknown to the vending machine ErrUnknownCoin = errors.New("Unknown coin") )
Functions ¶
This section is empty.
Types ¶
type VendingMachine ¶
type VendingMachine struct {
// contains filtered or unexported fields
}
VendingMachine holds the state of a vending machine
func NewVendingMachine ¶
func NewVendingMachine() *VendingMachine
NewVendingMachine returns a instantiated state of a vending machine
func (*VendingMachine) Coin ¶
func (v *VendingMachine) Coin(credit int) error
Coin inserts a coin into the vending machine. On success the credit of the machine will be increased by the coin.
func (VendingMachine) Credit ¶
func (v VendingMachine) Credit() int
Credit returns the current credit of the vending machine
func (*VendingMachine) Vend ¶
func (v *VendingMachine) Vend() bool
Vend executes a vend of the machine if enough credit (100) has been put in and returns true.
Click to show internal directories.
Click to hide internal directories.