implementation

package
v0.0.0-...-9f34108 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL