2 Star 7 Fork 0

严家豆 / Head first 设计模式学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MainTest.java 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
严家豆 提交于 2022-06-09 15:22 . update: 命令模式代码和UML更新
package OrderPattern.third;
import OrderPattern.third.appliance.CeilingFan;
import OrderPattern.third.appliance.Light;
import OrderPattern.third.command.CeilingFanOffCommand;
import OrderPattern.third.command.CeilingFanOnLowCommand;
import OrderPattern.third.command.LightOffCommand;
import OrderPattern.third.command.LightOnCommand;
public class MainTest {
public static void main(String[] args) throws Exception {
RemoteControl remoteControl = new RemoteControl();
CeilingFan ceilingFan = new CeilingFan();
Command CeilingFanOn = new CeilingFanOnLowCommand(ceilingFan);
Command CeilingFanOff = new CeilingFanOffCommand(ceilingFan);
remoteControl.setCommand(RemoteControl.SLOT1,CeilingFanOn,CeilingFanOff);
Light light = new Light();
Command LightOn = new LightOnCommand(light);
Command LightOff = new LightOffCommand(light);
remoteControl.setCommand(RemoteControl.SLOT2,LightOn,LightOff);
remoteControl.onButtonWasPressed(RemoteControl.SLOT1);
remoteControl.onButtonWasPressed(RemoteControl.SLOT2);
remoteControl.undoButtonWasPressed();
}
}
Java
1
https://gitee.com/yan-jiadou/design-mode.git
git@gitee.com:yan-jiadou/design-mode.git
yan-jiadou
design-mode
Head first 设计模式学习
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891