go-pattern-examples/structure/13_composite/composite.go

27 lines
521 B
Go
Raw Normal View History

2020-05-01 18:43:34 +03:00
package composite
//ItemType 具体物品的类型
type ItemType int
//定义两种数据类型,叶子和复合节点
const (
ManCloth ItemType = iota
WomanCloth
HatOrShose
)
//IWearingItem 定义复合类型的接口,表示穿戴物品
type IWearingItem interface {
GetWearingType() ItemType
}
//CompositedComponet 复合类型,复合类型知道所有的具体类型
type CompositedComponet struct {
}
//NewComponent return a concrate
func NewComponent(kind int, name string) IWearingItem {
return nil
}