example

package
v0.0.0-...-db5681a Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caretaker

type Caretaker struct {
	Originator Originator
	History    []*Memento
}

负责人类

func (*Caretaker) AddMemento

func (c *Caretaker) AddMemento(m *Memento)

添加备忘录

func (*Caretaker) GetMemento

func (c *Caretaker) GetMemento(index int) *Memento

获取备忘录

type Memento

type Memento struct {
	// contains filtered or unexported fields
}

备忘录 Memento 存储原发器 Originator 的状态

func NewMemento

func NewMemento(value int) *Memento

创建一个新的备忘录*Memento

type Originator

type Originator struct {
	// contains filtered or unexported fields
}

Originator 代表一个可以被操作的整数

func NewOriginator

func NewOriginator(value int) *Originator

NewOriginator 创建一个新的原发器 Originator

func (*Originator) CreateMemento

func (n *Originator) CreateMemento() *Memento

使用原发器创建一个备忘录 Memento

func (*Originator) HalfTimes

func (n *Originator) HalfTimes()

获取数字值的一半

func (*Originator) RestoreMemento

func (n *Originator) RestoreMemento(memento *Memento)

将原发器 Originator 的值恢复为指定版本的备忘录的值

func (*Originator) TenTimes

func (n *Originator) TenTimes()

将数字的值乘以10倍

func (*Originator) Value

func (n *Originator) Value() int

返回数字的值

Jump to

Keyboard shortcuts

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