示例#1
0
        static void Main(string[] args)
        {
            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");

            // Wait for user

            Console.ReadKey();
        }
        public void Main()
        {
            var 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();
        }
        public void Test()
        {
            Chatroom    room = new Chatroom();
            Participant p1   = new Beatle("A");
            Participant p2   = new NoBeatle("B");
            Participant p3   = new NoBeatle("C");

            room.Register(p1);
            room.Register(p2);
            room.Register(p3);
            p1.Send("B", "hello B");
            p1.Send("C", "hello C");
            p2.Send("A", "hello A");
            p3.Send("A", "hello A");
            p3.Send("B", "hello B");
            Console.ReadLine();
        }