Beispiel #1
0
        static void Main(string[] args)
        {
            TextChat chat = new TextChat();

            IUser admin = new Admin(chat, "Иван Иваныч");
            IUser user1 = new SimpleUser(chat, "Sergey");
            IUser user2 = new SimpleUser(chat, "Dasha");
            IUser user3 = new SimpleUser(chat, "Masha");

            user2.setEnable(false);

            chat.setAdmin(admin);
            chat.addUser(user1);
            chat.addUser(user2);
            chat.addUser(user3);

            user1.sendMessage("Hello, I'm user");
            admin.sendMessage("Admin online!!!");
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            // Чат.
            var chat = new TextChat();

            // Пользователи.
            var admin         = new Admin(chat, "Adm");
            var normalUserOne = new NormalUser(chat, "AC");
            var normalUserTwo = new NormalUser(chat, "DC");

            // Добавление пользователей в чат.
            chat.Admin = admin;
            chat.AddUserInChat(normalUserOne);
            chat.AddUserInChat(normalUserTwo);

            // Общение.
            normalUserOne.SendMessage("Where is my DC?");
            normalUserTwo.SendMessage("I'm here!!");
            admin.SendMessage("Back in black!");

            Console.ReadKey();
        }