Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var chatRoom = new ChatRoom();

            var user1 = new CommonUser("小明");
            var user2 = new GoldenUser("小豪");
            var user3 = new Administrator("小蛤");

            chatRoom.register(user1);
            chatRoom.register(user2);
            chatRoom.register(user3);

            user1.send("Hello,world");
            user2.send("买辆兰博基尼怎么样");
            user3.send("开门,快递");

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("========中介者模式-測試========");

            Messager jacky = new VIPUser("Jacky");
            Messager huant = new VIPUser("Huant");
            Messager neil  = new CommonUser("Neil");

            MessageMediator.joinChat(jacky);
            MessageMediator.joinChat(huant);
            MessageMediator.joinChat(neil);

            Console.WriteLine("---VIP會員直接送訊息給所有人---");
            jacky.sendToAll("安安! 26歲 基隆男");

            Console.WriteLine("---私下密語---");
            jacky.send("走啦~去看附醜者聯盟啊!", huant);
            neil.send("收假了!掰~", jacky);

            Console.WriteLine("---非VIP會員想尬廣---");
            neil.sendToAll("幹你娘雞掰勒!不想收假啊!!!!!!!");
        }