Documentation
¶
Index ¶
- type HasMoneyState
- type HasProductState
- type NoProductState
- type ProductRequestedState
- type State
- type VendingMachine
- func (v *VendingMachine) AddProduct(count int) error
- func (v *VendingMachine) DispenseProduct() error
- func (v *VendingMachine) IncrementProductCount(count int)
- func (v *VendingMachine) InsertMoney(money int) error
- func (v *VendingMachine) RequestProduct() error
- func (v *VendingMachine) SetState(s State)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HasMoneyState ¶
type HasMoneyState struct {
VendingMachine *VendingMachine
}
func (*HasMoneyState) AddProduct ¶
func (i *HasMoneyState) AddProduct(count int) error
func (*HasMoneyState) DispenseProduct ¶
func (i *HasMoneyState) DispenseProduct() error
func (*HasMoneyState) InsertMoney ¶
func (i *HasMoneyState) InsertMoney(money int) error
func (*HasMoneyState) RequestProduct ¶
func (i *HasMoneyState) RequestProduct() error
type HasProductState ¶
type HasProductState struct {
VendingMachine *VendingMachine
}
func (*HasProductState) AddProduct ¶
func (i *HasProductState) AddProduct(count int) error
func (*HasProductState) DispenseProduct ¶
func (i *HasProductState) DispenseProduct() error
func (*HasProductState) InsertMoney ¶
func (i *HasProductState) InsertMoney(money int) error
func (*HasProductState) RequestProduct ¶
func (i *HasProductState) RequestProduct() error
type NoProductState ¶
type NoProductState struct {
VendingMachine *VendingMachine
}
func (*NoProductState) AddProduct ¶
func (i *NoProductState) AddProduct(count int) error
func (*NoProductState) DispenseProduct ¶
func (i *NoProductState) DispenseProduct() error
func (*NoProductState) InsertMoney ¶
func (i *NoProductState) InsertMoney(money int) error
func (*NoProductState) RequestProduct ¶
func (i *NoProductState) RequestProduct() error
type ProductRequestedState ¶
type ProductRequestedState struct {
VendingMachine *VendingMachine
}
func (*ProductRequestedState) AddProduct ¶
func (i *ProductRequestedState) AddProduct(count int) error
func (*ProductRequestedState) DispenseProduct ¶
func (i *ProductRequestedState) DispenseProduct() error
func (*ProductRequestedState) InsertMoney ¶
func (i *ProductRequestedState) InsertMoney(money int) error
func (*ProductRequestedState) RequestProduct ¶
func (i *ProductRequestedState) RequestProduct() error
type VendingMachine ¶
type VendingMachine struct {
// contains filtered or unexported fields
}
自动售货机类
func NewVendingMachine ¶
func NewVendingMachine(productCount, productPrice int) *VendingMachine
func (*VendingMachine) AddProduct ¶
func (v *VendingMachine) AddProduct(count int) error
func (*VendingMachine) DispenseProduct ¶
func (v *VendingMachine) DispenseProduct() error
func (*VendingMachine) IncrementProductCount ¶
func (v *VendingMachine) IncrementProductCount(count int)
func (*VendingMachine) InsertMoney ¶
func (v *VendingMachine) InsertMoney(money int) error
func (*VendingMachine) RequestProduct ¶
func (v *VendingMachine) RequestProduct() error
func (*VendingMachine) SetState ¶
func (v *VendingMachine) SetState(s State)
Click to show internal directories.
Click to hide internal directories.