static void Main(string[] args)
        {
            // 開店前的準備
            Barbecuer      barbecuer               = new Barbecuer();
            ExampleCommand bakeMuttonCommand1      = new BakeMuttonCommand(barbecuer);
            ExampleCommand bakeMuttonCommand2      = new BakeMuttonCommand(barbecuer);
            ExampleCommand bakeChickenWingCommand1 = new BakeChickenWingCommand(barbecuer);
            Waiter         waiter = new Waiter();

            // 開門營業
            waiter.SetOrder(bakeMuttonCommand1);
            waiter.SetOrder(bakeMuttonCommand2);
            waiter.SetOrder(bakeChickenWingCommand1);

            // 點菜完畢,通知廚房
            waiter.Notify();

            Console.WriteLine("\n");

            Receiver receiver = new Receiver();
            Command  command  = new ConcreteCommand(receiver);
            Invoker  invoker  = new Invoker();

            invoker.SetCommand(command);
            invoker.ExecuteCommand();

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            Barbecuer barbecuer       = new Barbecuer();
            Command   bakeMutton      = new BakeMuttonCommand(barbecuer);
            Command   bakeChickenWing = new BakeChickenWingCommand(barbecuer);
            Waiter    waiter          = new Waiter();

            waiter.SetOrder(bakeMutton);
            waiter.SetOrder(bakeChickenWing);

            waiter.Notify();
        }
示例#3
0
        static void Main(string[] args)
        {
            Barbecuer boy = new Barbecuer();
            Command   bakeMuttonCommand1      = new BakeMuttonCommand(boy);
            Command   bakeMuttonCommand2      = new BakeMuttonCommand(boy);
            Command   bakeChickenWingCommand1 = new BakeChickenWingCommand(boy);
            Waiter    girl = new Waiter();

            girl.SetOrder(bakeMuttonCommand1);
            girl.SetOrder(bakeMuttonCommand2);
            girl.SetOrder(bakeChickenWingCommand1);

            girl.Notify();

            Console.Read();
        }
示例#4
0
        static void Main(string[] args)
        {
            //開店前準備
            Barbecuer boy  = new Barbecuer();
            Command   cmd1 = new BakeMuttonCommand(boy);
            Command   cmd2 = new BakeMuttonCommand(boy);
            Command   cmd3 = new BakeChickenWingCommand(boy);
            Waiter    girl = new Waiter();

            //營業 點餐
            girl.SetOrder(cmd1);
            girl.SetOrder(cmd2);
            girl.SetOrder(cmd3);

            //點完通知廚房
            girl.Notify();
            Console.ReadKey();
        }