Beispiel #1
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Create chatroom
            Chatroom chatroom = new Chatroom();

            // Create participants and register them
            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);

            // Chatting participants
            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();
        }
        static void Main()
        {
            // Create chatroom
            Chatroom chatroom = new Chatroom();

            // Create colleagues and register them
            Colleague Ann = new FromMainCompant("Ann");
            Colleague Arthur = new FromMainCompant("Arthur");
            Colleague Jack = new FromMainCompant("Jack");
            Colleague John = new FromMainCompant("John");
            //Mery is from other company, but she can talk  with them
            Colleague Mery = new FromOtherCompany("Mery");

            chatroom.Register(Ann);
            chatroom.Register(Arthur);
            chatroom.Register(Jack);
            chatroom.Register(John);
            chatroom.Register(Mery);

            // Chatting colleagues
            Mery.Send("John", "Hi John!");
            Arthur.Send("Jack", "How are you?");
            Jack.Send("Ann", "Hello");
            Arthur.Send("John", "What are you doing John?");
            John.Send("Mery", "You are Welcome");
        }