1700463441
1700463442
代码清单15-16 具体的Command类
1700463443
1700463444
public class ConcreteCommand1 extends Command{
1700463445
1700463446
//对哪个Receiver类进行命令处理
1700463447
1700463448
private Receiver receiver;
1700463449
1700463450
//构造函数传递接收者
1700463451
1700463452
public ConcreteCommand1(Receiver_receiver){
1700463453
1700463454
this.receiver=_receiver;
1700463455
1700463456
}
1700463457
1700463458
//必须实现一个命令
1700463459
1700463460
public void execute(){
1700463461
1700463462
//业务处理
1700463463
1700463464
this.receiver.doSomething();
1700463465
1700463466
}
1700463467
1700463468
}
1700463469
1700463470
public class ConcreteCommand2 extends Command{
1700463471
1700463472
//哪个Receiver类进行命令处理
1700463473
1700463474
private Receiver receiver;
1700463475
1700463476
//构造函数传递接收者
1700463477
1700463478
public ConcreteCommand2(Receiver_receiver){
1700463479
1700463480
this.receiver=_receiver;
1700463481
1700463482
}
1700463483
1700463484
//必须实现一个命令
1700463485
1700463486
public void execute(){
1700463487
1700463488
//业务处理
1700463489
1700463490
this.receiver.doSomething();
[
上一页 ]
[ :1.700463441e+09 ]
[
下一页 ]