DesignPattern/18.MediatorPattern/2.Code/Tenant.cpp

25 lines
377 B
C++
Raw Permalink Normal View History

2019-11-03 23:46:24 +00:00
#include "Colleague.h"
#include "Mediator.h"
2021-10-28 15:15:51 +00:00
Tenant::Tenant()
{
2019-11-03 23:46:24 +00:00
name = "none";
setPersonType(NONE_PERSON);
}
2021-10-28 15:15:51 +00:00
Tenant::Tenant(string iName)
{
2019-11-03 23:46:24 +00:00
name = iName;
setPersonType(TENANT);
}
2021-10-28 15:15:51 +00:00
void Tenant::ask()
{
printf("租客%s询问房东信息\n", name.c_str());
2019-11-03 23:46:24 +00:00
(this->getMediator())->operation(this);
}
2021-10-28 15:15:51 +00:00
void Tenant::answer()
{
printf("租客姓名:%s\n", name.c_str());
2019-11-03 23:46:24 +00:00
}