mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-12-01 15:46:02 +03:00
24 lines
537 B
Go
24 lines
537 B
Go
|
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
|
||
|
|
||
|
}
|