go知识重新整理

This commit is contained in:
Estom
2021-09-03 05:34:34 +08:00
parent 62309f856a
commit 1bad082e49
291 changed files with 29345 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
/**
* @Author:zhoutao
* @Date:2020/12/12 上午11:40
* @Desc:
*/
package command
//将"方法调用"封装到对象中,方便传输、调用、存储
func ExampleCommand() {
mb := &MotherBoard{}
startCommand := NewStartCommand(mb)
rebootCommond := NewRebootCommand(mb)
box1 := NewBox(startCommand, rebootCommond)
box1.PressButton1()
box1.PressButton2()
//output:
//system starting
//system rebooting
box2 := NewBox(rebootCommond, startCommand)
box2.PressButton1()
box2.PressButton2()
//output:
//system rebooting
//system starting
}