Skip to content

Commit

Permalink
fix typo: buttion -> button
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec authored and senghoo committed Jun 22, 2020
1 parent ef73f66 commit 5f7a072
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions 11_command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

示例中把主板单中的启动(start)方法和重启(reboot)方法封装为命令对象,再传递到主机(box)对象中。于两个按钮进行绑定:

* 第一个机箱(box1)设置按钮1(buttion1) 为开机按钮2(buttion2)为重启。
* 第二个机箱(box1)设置按钮2(buttion2) 为开机按钮1(buttion1)为重启。
* 第一个机箱(box1)设置按钮1(button1) 为开机按钮2(button2)为重启。
* 第二个机箱(box1)设置按钮2(button2) 为开机按钮1(button1)为重启。

从而得到配置灵活性。

Expand Down
18 changes: 9 additions & 9 deletions 11_command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ func (*MotherBoard) Reboot() {
}

type Box struct {
buttion1 Command
buttion2 Command
button1 Command
button2 Command
}

func NewBox(buttion1, buttion2 Command) *Box {
func NewBox(button1, button2 Command) *Box {
return &Box{
buttion1: buttion1,
buttion2: buttion2,
button1: button1,
button2: button2,
}
}

func (b *Box) PressButtion1() {
b.buttion1.Execute()
func (b *Box) PressButton1() {
b.button1.Execute()
}

func (b *Box) PressButtion2() {
b.buttion2.Execute()
func (b *Box) PressButton2() {
b.button2.Execute()
}
8 changes: 4 additions & 4 deletions 11_command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ func ExampleCommand() {
rebootCommand := NewRebootCommand(mb)

box1 := NewBox(startCommand, rebootCommand)
box1.PressButtion1()
box1.PressButtion2()
box1.PressButton1()
box1.PressButton2()

box2 := NewBox(rebootCommand, startCommand)
box2.PressButtion1()
box2.PressButtion2()
box2.PressButton1()
box2.PressButton2()
// Output:
// system starting
// system rebooting
Expand Down

0 comments on commit 5f7a072

Please sign in to comment.