2019-11-03 23:46:24 +00:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include "Mediator.h"
|
|
|
|
|
#include "Colleague.h"
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2021-10-28 15:15:51 +00:00
|
|
|
|
// 创建租房中介
|
2019-11-03 23:46:24 +00:00
|
|
|
|
Agency *mediator = new Agency();
|
|
|
|
|
|
2021-10-28 15:15:51 +00:00
|
|
|
|
// 创建3位房东
|
|
|
|
|
Landlord *fangdong1 = new Landlord("刘备", 1350, "成都市双流区", "1351025");
|
|
|
|
|
Landlord *fangdong2 = new Landlord("关羽", 1500, "成都市武侯区", "1378390");
|
|
|
|
|
Landlord *fangdong3 = new Landlord("张飞", 1000, "成都市龙泉驿", "1881166");
|
2019-11-03 23:46:24 +00:00
|
|
|
|
fangdong1->setMediator(mediator);
|
|
|
|
|
fangdong2->setMediator(mediator);
|
|
|
|
|
fangdong3->setMediator(mediator);
|
2021-10-28 15:15:51 +00:00
|
|
|
|
// 房东在中介处登记注册房源信息
|
2019-11-03 23:46:24 +00:00
|
|
|
|
mediator->registerMethod(fangdong1);
|
|
|
|
|
mediator->registerMethod(fangdong2);
|
|
|
|
|
mediator->registerMethod(fangdong3);
|
|
|
|
|
|
2021-10-28 15:15:51 +00:00
|
|
|
|
// 创建两位租客Jungle和贱萌兔
|
2019-11-03 23:46:24 +00:00
|
|
|
|
Tenant *jungle = new Tenant("Jungle");
|
2021-10-28 15:15:51 +00:00
|
|
|
|
Tenant *jianmengtu = new Tenant("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2019-11-03 23:46:24 +00:00
|
|
|
|
jungle->setMediator(mediator);
|
|
|
|
|
jianmengtu->setMediator(mediator);
|
2021-10-28 15:15:51 +00:00
|
|
|
|
// Jungle和贱萌兔在中介处登记求租信息
|
2019-11-03 23:46:24 +00:00
|
|
|
|
mediator->registerMethod(jungle);
|
|
|
|
|
mediator->registerMethod(jianmengtu);
|
|
|
|
|
|
|
|
|
|
jungle->ask();
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
fangdong1->ask();
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
system("pause");
|
2020-11-29 03:17:40 +00:00
|
|
|
|
|
|
|
|
|
delete mediator;
|
|
|
|
|
delete fangdong1;
|
|
|
|
|
delete fangdong2;
|
|
|
|
|
delete fangdong3;
|
|
|
|
|
delete jungle;
|
|
|
|
|
delete jianmengtu;
|
2022-03-09 23:53:38 +00:00
|
|
|
|
mediator = nullptr;
|
|
|
|
|
fangdong1 = nullptr;
|
|
|
|
|
fangdong2 = nullptr;
|
|
|
|
|
fangdong3 = nullptr;
|
|
|
|
|
jungle = nullptr;
|
|
|
|
|
jianmengtu = nullptr;
|
2020-11-29 03:17:40 +00:00
|
|
|
|
|
2019-11-03 23:46:24 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|