update visitor pattern

This commit is contained in:
Edward 2020-05-04 23:05:00 +08:00
parent 7787fba31b
commit 16d5b8d8d4
2 changed files with 4 additions and 4 deletions

View File

@ -2,8 +2,8 @@ package visitor
import "fmt" import "fmt"
//IGameContext 游戏上下文 //IGameObject 游戏上下文对象
type IGameContext interface { type IGameObject interface {
Accept(IGameVisitor) Accept(IGameVisitor)
} }

View File

@ -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)