mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-25 13:16:02 +03:00
21 lines
415 B
Go
21 lines
415 B
Go
package command
|
|
|
|
func ExampleCommand() {
|
|
mb := &MotherBoard{}
|
|
startCommand := NewStartCommand(mb)
|
|
rebootCommand := NewRebootCommand(mb)
|
|
|
|
box1 := NewBox(startCommand, rebootCommand)
|
|
box1.PressButtion1()
|
|
box1.PressButtion2()
|
|
|
|
box2 := NewBox(rebootCommand, startCommand)
|
|
box2.PressButtion1()
|
|
box2.PressButtion2()
|
|
// Output:
|
|
// system starting
|
|
// system rebooting
|
|
// system rebooting
|
|
// system starting
|
|
}
|