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);
        }
Example #2
0
        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();
        }
Example #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();
        }