コード例 #1
0
        static void Main(string[] args)
        {
            IMediator mediator = new Mediator();

            Employee waiter = new Waiter("John", mediator);
            Employee cook   = new Cook("Jack", mediator);

            mediator.Register(waiter);
            mediator.Register(cook);

            waiter.Send("Jack", "Cheesecake ordered!");
            cook.Send("John", "Cheesecake is ready!");

            Console.ReadKey(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: CosmosIsBeautiful/C-Sharp
        static void Main()
        {
            var mediator = new ConcreteMediator();
            var waiter   = new Waiter(mediator);
            var cook     = new Cook(mediator);

            mediator.Waiter = waiter;
            mediator.Cook   = cook;

            Console.WriteLine("Официант ожидает заказ:");
            string order = Console.ReadLine();

            waiter.TakeAnOrder(order);

            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            ConcreteMediator mediator = new ConcreteMediator();

            Actor visitor = new Visitor(mediator);
            Actor cashier = new Cashier(mediator);
            Actor cook    = new Cook(mediator);

            mediator.Visitor = visitor;
            mediator.Cashier = cashier;
            mediator.Cook    = cook;

            visitor.Send("гамбургер");
            cashier.Send("Гамбургер");
            cook.Send("гамбургер");

            Console.ReadKey();
        }