Beispiel #1
0
 public override void Communication(string msg, Person person)
 {
     //如果是房东则通知租客
     if (person is Landlord)
     {
         Tenant.ReceiveNotify(msg);
     }
     else //如果是租客则通知房东
     {
         Landlord.ReceiveNotify(msg);
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            //创建中介、房东与租客
            HouseMediator mediator = new HouseMediator("房屋中介张先生");
            Person landlord = new Landlord("林房东", mediator);
            Person tenant = new Tenant("孙同学", mediator);

            mediator.Landlord = landlord;
            mediator.Tenant = tenant;

            //租客与房东分别发起会话  会话内容都是通过中介传递给对方的
            tenant.Send("我要租一间20平米的单间");
            landlord.Send("我这儿正好有一间,3000一个月");

            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //创建中介、房东与租客
            HouseMediator mediator = new HouseMediator("房屋中介张先生");
            Person        landlord = new Landlord("林房东", mediator);
            Person        tenant   = new Tenant("孙同学", mediator);

            mediator.Landlord = landlord;
            mediator.Tenant   = tenant;

            //租客与房东分别发起会话  会话内容都是通过中介传递给对方的
            tenant.Send("我要租一间20平米的单间");
            landlord.Send("我这儿正好有一间,3000一个月");

            Console.ReadLine();
        }