mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-22 03:46:03 +03:00
update visitor pattern
This commit is contained in:
parent
7787fba31b
commit
16d5b8d8d4
@ -2,8 +2,8 @@ package visitor
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
//IGameContext 游戏上下文
|
//IGameObject 游戏上下文对象
|
||||||
type IGameContext interface {
|
type IGameObject interface {
|
||||||
Accept(IGameVisitor)
|
Accept(IGameVisitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package visitor
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestVisitor(t *testing.T) {
|
func TestSingleVisitor(t *testing.T) {
|
||||||
|
|
||||||
//汽油提供给,制衣工厂
|
//汽油提供给,制衣工厂
|
||||||
g := gas{density: 100}
|
g := gas{density: 100}
|
||||||
@ -32,7 +32,7 @@ func TestGameVisitorsList(t *testing.T) {
|
|||||||
env := SystemEnv{"made by china", "v1.2.11"}
|
env := SystemEnv{"made by china", "v1.2.11"}
|
||||||
|
|
||||||
//游戏对象
|
//游戏对象
|
||||||
gameObjects := []IGameContext{pA, npc, env, pB}
|
gameObjects := []IGameObject{pA, npc, env, pB}
|
||||||
|
|
||||||
for _, v := range gameObjects {
|
for _, v := range gameObjects {
|
||||||
v.Accept(retriveSetting)
|
v.Accept(retriveSetting)
|
||||||
|
Loading…
Reference in New Issue
Block a user