百科知识

命令模式(Command)讲解是什?命令模式(Command)讲

2018-03-22 04:36:36李***
命令模式(Command)讲解是什么命令模式(Command)讲解是什?命令模式(Command)讲解是什么:JAVA的命令模式(Command)相信大家都了解吧,一起来看下面的代码。 publi?

最佳回答

  •   JAVA的命令模式(Command)相信大家都了解吧,一起来看下面的代码。 public class Invoker { private Command command; public Invoker(Command command) { this。
      command=command; } public void action() { command。action(); } } public class Receiver { public Receiver() { 。。。 } public void action() { System。
      out。println("Action has been taken。"); } } public interface Command { void execute(); } public class ConcreteCommand implements Command { private Receiver receiver; public ConcreteCommand(Receiver receiver) { this。
      receiver=receiver; } public void execute() { receiver。action(); } } public class Client { public static void main(String[] args) { Receiver receiver=new Receiver(); Command command=new ConcreteCommand(receiver); Invoker invoker=new Invoker(command); invoker。
      action(); } }。
    2018-03-22 04:05:43
  • 很赞哦! (272)