设计模式 chain_test 实现
golang 设计模式 chain_test 代码实现
package chain
func ExampleChain() {
c1 := NewProjectManagerChain()
c2 := NewDepManagerChain()
c3 := NewGeneralManagerChain()
c1.SetSuccessor(c2)
c2.SetSuccessor(c3)
var c Manager = c1
c.HandleFeeRequest("bob", 400)
c.HandleFeeRequest("tom", 1400)
c.HandleFeeRequest("ada", 10000)
c.HandleFeeRequest("floar", 400)
// Output:
// Project manager permit bob 400 fee request
// Dep manager permit tom 1400 fee request
// General manager permit ada 10000 fee request
// Project manager don't permit floar 400 fee request
}
目录
相关文章
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦