예제 #1
0
        static void Main(string[] args)
        {
            //Create chatroom (concrete Mediator)
            Chatroom chatroom = new Chatroom();

            //Create Participants and register them
            Participant greg    = new Beatle("Greg");
            Participant john    = new Beatle("John");
            Participant anna    = new Beatle("Anna");
            Participant doe     = new Beatle("Doe");
            Participant charlie = new Beatle("Charlie");
            Participant fuzz    = new NonBeatle("Fuzz");

            //register
            chatroom.Register(greg);
            chatroom.Register(john);
            chatroom.Register(anna);
            chatroom.Register(doe);
            chatroom.Register(charlie);
            chatroom.Register(fuzz);

            //Chatting participants
            greg.Send("John", "Hi John!");
            john.Send("Anna", "Hi Anna!");
            anna.Send("Doe", "How are you Doe?");
            doe.Send("Charlie", "Howdy Charlie?");
            charlie.Send("Fuzz", "Hiya Fuzz!!");

            Console.ReadKey();
        }
예제 #2
0
        static void Main()
        {
            Chatroom chatroom = new Chatroom();

            Participant George = new Beatle("George");
            Participant Paul   = new Beatle("Paul");
            Participant Ringo  = new Beatle("Ringo");
            Participant John   = new Beatle("John");
            Participant Yoko   = new NonBeatle("Yoko");

            chatroom.Register(George);
            chatroom.Register(Paul);
            chatroom.Register(Ringo);
            chatroom.Register(John);
            chatroom.Register(Yoko);

            Yoko.Send("John", "Hi John!");
            Paul.Send("Ringo", "All you need is love");
            Ringo.Send("George", "My sweet Lord");
            Paul.Send("John", "Can't buy me love");
            John.Send("Yoko", "My sweet love");

            Console.ReadKey();
        }