DesignPattern/18.MediatorPattern/2.Code/Colleague.h

63 lines
1.0 KiB
C
Raw Normal View History

2019-11-03 23:46:24 +00:00
#ifndef __COLLEAGUE_H__
#define __COLLEAGUE_H__
#include "common.h"
using namespace std;
2021-10-28 15:15:51 +00:00
// 前向声明
2019-11-03 23:46:24 +00:00
class Mediator;
class Agency;
2021-10-28 15:15:51 +00:00
// 抽象同事类
2019-11-03 23:46:24 +00:00
class Colleague
{
public:
Colleague(){}
virtual ~Colleague(){}
2019-11-03 23:46:24 +00:00
void setMediator(Mediator* iMediator){
this->mediator = iMediator;
}
Mediator* getMediator(){
return this->mediator;
}
void setPersonType(PERSON_TYPE iPersonType){
this->personType = iPersonType;
}
PERSON_TYPE getPersonType(){
return this->personType;
}
virtual void ask() = 0;
virtual void answer() = 0;
private:
PERSON_TYPE personType;
Mediator* mediator;
};
2021-10-28 15:15:51 +00:00
// 具体同事类:房东
2019-11-03 23:46:24 +00:00
class Landlord :public Colleague
{
public:
Landlord();
Landlord(string iName, int iPrice, string iAddress, string iPhoneNum);
void ask();
void answer();
private:
string name;
int price;
string address;
string phoneNumber;
};
2021-10-28 15:15:51 +00:00
// 具体同事类:租客
2019-11-03 23:46:24 +00:00
class Tenant :public Colleague
{
public:
Tenant();
Tenant(string name);
void ask();
void answer();
private:
string name;
};
#endif //__COLLEAGUE_H__