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();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            //Receiver r = new Receiver();
            //Command c = new ConcreteCommand(r);

            //Invoke i = new Invoke();
            //i.SetCommand(c);
            //i.ExecCommand();

            Barbecuer boy = new Barbecuer();

            AbstractCommand bakeMuttonCommand1 = new BakeMuttonCommond(boy);

            AbstractCommand bakeMuttonCommand2 = new BakeMuttonCommond(boy);

            AbstractCommand bakeChickenCommand = new BakeChickenWingCommond(boy);

            Waiter girl = new Waiter();

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

            girl.Notify();
            Console.ReadKey();
        }
Example #3
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();
        }
Example #4
0
        private static void Main(string[] args)
        {
            var      boy = new Barbecuer();
            Commands bakeMuttonCommand1      = new BakeMuttonCommand(boy);
            Commands bakeMuttonCommand2      = new BakeMuttonCommand(boy);
            Commands bakeChickenWingCommand1 = new BakeChickenWing(boy);

            Waiter girl = new Waiter();

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

            Console.Read();
        }
Example #5
0
        static void Main(string[] args)
        {
            Barbecuer boy         = new Barbecuer();
            Command   bakemutton1 = new BakeMuttonCommand(boy);
            Command   bakemutton2 = new BakeMuttonCommand(boy);
            Command   bakeChick   = new BakeChickenWingCommand(boy);

            Waiter girl = new Waiter();

            girl.SetOrder(bakemutton1);
            girl.SetOrder(bakemutton2);
            girl.SetOrder(bakeChick);

            girl.Notify();

            Console.ReadKey();
        }
Example #6
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();
        }