go-pattern-examples/behavior/17_memento/memento_test.go
2020-04-21 22:53:23 +08:00

23 lines
278 B
Go

package memento
func ExampleGame() {
game := &Game{
hp: 10,
mp: 10,
}
game.Status()
progress := game.Save()
game.Play(-2, -3)
game.Status()
game.Load(progress)
game.Status()
// Output:
// Current HP:10, MP:10
// Current HP:7, MP:8
// Current HP:10, MP:10
}