Example #1
0
        static void Main(string[] args)
        {
            Invoker invoker = new Invoker();

            ReceiverRobot robot = new ReceiverRobot();

            GoAheadCommand   cmd_goAhead   = new GoAheadCommand(robot);
            TurnLeftCommand  cmd_turnLeft  = new TurnLeftCommand(robot);
            TurnRightCommand cmd_turnRight = new TurnRightCommand(robot);


            invoker.SetCommand(cmd_goAhead);
            invoker.SetCommand(cmd_goAhead);
            invoker.SetCommand(cmd_turnLeft);
            invoker.SetCommand(cmd_turnRight);
            invoker.SetCommand(cmd_turnLeft);
            invoker.SetCommand(cmd_goAhead);
            invoker.SetCommand(cmd_turnLeft);

            invoker.Run();

            Console.ReadLine();
        }
Example #2
0
 public TurnLeftCommand(ReceiverRobot robot) : base(robot)
 {
 }
Example #3
0
 public TurnRightCommand(ReceiverRobot robot) : base(robot)
 {
 }
Example #4
0
 public GoAheadCommand(ReceiverRobot robot) : base(robot)
 {
 }
Example #5
0
 // 設定實際執行命令的物件
 public Command(ReceiverRobot robot)
 {
     this.robot = robot;
 }