コード例 #1
0
        static void Main(string[] args)
        {
            Soliders soliders         = new Soliders();
            Command  combinateCommand = new CombinateCommand(soliders);
            Command  fightCommand     = new FightCommand(soliders);
            Command  cableBoatCommand = new CableBoatCommand(soliders);

            //设置传令官
            Herald herald = new Herald();

            //集合
            herald.SetCommand(combinateCommand);
            //herald.Notify();

            //战斗
            herald.SetCommand(fightCommand);
            herald.SetCommand(fightCommand);
            // herald.Notify();

            //铁索连舟
            herald.SetCommand(cableBoatCommand);
            //herald.Notify();
            herald.Notify();
            Console.WriteLine("取消命令!");
            herald.CancelCommand(cableBoatCommand);
            herald.Notify();

            Reciver    reciver = new Reciver();
            AbsCommand command = new ConcreteCommand(reciver);
            Invoker    invoker = new Invoker();

            invoker.SetCommand(command);
            invoker.ExecuteCommand();
        }
コード例 #2
0
 public ConcreteCommand(Reciver reciver) : base(reciver)
 {
 }
コード例 #3
0
 public AbsCommand(Reciver reciver)
 {
     this.reciver = reciver;
 }