3、c abstract class Command...{ protected Receiver receiver; public Command(Receiver receiver) ...{ this.receiver = receiver; }//end Command(...) abstract public void execute(); }//end abstract class Command再继承一个具体类:package C
4、ommand;public class ConcreteCommand extends Command...{ public ConcreteCommand( Receiver receiver ) ...{ super(receiver); }//end ConcreteCommand(...) public void execute() ...{ receiver.action(); }//end execute()
5、}//end class ConcreteCommand定义一个Receiver类:package Command;public class Receiver...{ public void action() ...{ System.out.println("Receiver.Action()"); }//end Action() }//end class Receiver定义一个Invoker类:package Command;class Invoker
7、d class Invoker最后是调用:package Command;public class CommandPattern...{ Receiver rceiver = new Receiver(); Command command = new ConcreteCommand(rceiver); Invoker invoker = new Invoker(); /** *//** Creates a new instance of CommandPattern */
8、 public CommandPattern() ...{ }//end CommandPattern public void showCommandPattern() ...{ invoker.setCommand(command); invoker.executeCommand(); }//end showCommandPattern() public stati