예제 #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
        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();
        }