代码拉取完成,页面将自动刷新
同步操作将从 serv/JavaDesigner 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: The9.com</p>
* @author Jerry Shen
* @version 0.5
*/
public class TestCommand {
public TestCommand() {
}
public static void main(String[] args) {
Light testLight = new Light();
LightOnCommand testLOC = new LightOnCommand(testLight);
LightOffCommand testLFC = new LightOffCommand(testLight);
Switch testSwitch = new Switch(testLOC, testLFC);
testSwitch.flipUp( );
testSwitch.flipDown( );
Fan testFan = new Fan( );
FanOnCommand foc = new FanOnCommand(testFan);
FanOffCommand ffc = new FanOffCommand(testFan);
Switch ts = new Switch( foc,ffc);
ts.flipUp( );
ts.flipDown( );
}
}
//---------- Class Fan ------------------------------
class Fan {
public void startRotate() {
System.out.println("Fan is Rotating now !");
}
public void stopRotate() {
System.out.println("Fan is stop now !");
}
}
//-----------------------------------------------------
//---------- Class Light ----------------------------
class Light {
public void turnOn() {
System.out.println("Light is on now !");
}
public void turnOff() {
System.out.println("Light is off now !");
}
}
//-----------------------------------------------------
//---------- Class Switch ---------------------------
class Switch {
private Command UpCommand, DownCommand;
public Switch (Command Up, Command Down) {
UpCommand = Up;
DownCommand = Down;
}
void flipUp() {
UpCommand.execute();
}
void flipDown() {
DownCommand.execute();
}
}
//-----------------------------------------------------
//---------- Class LightOnCommand -------------------
class LightOnCommand implements Command {
private Light myLight;
public LightOnCommand (Light L) {
myLight = L;
}
public void execute() {
myLight.turnOn();
}
}
//-----------------------------------------------------
//---------- Class LightOffCommand ------------------
class LightOffCommand implements Command {
private Light myLight;
public LightOffCommand (Light L) {
myLight = L;
}
public void execute() {
myLight.turnOff();
}
}
//-----------------------------------------------------
//---------- Class FanOnCommand ---------------------
class FanOnCommand implements Command {
private Fan myFan;
public FanOnCommand (Fan F) {
myFan = F;
}
public void execute() {
myFan.startRotate();
}
}
//-----------------------------------------------------
//---------- Class FanOffCommand ---------------------
class FanOffCommand implements Command {
private Fan myFan;
public FanOffCommand (Fan F) {
myFan = F;
}
public void execute() {
myFan.stopRotate();
}
}
//-----------------------------------------------------
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。