void HandleCall(Call &call)
class Employee {
Handler h;
public:
bool free;
void ReceiveCall (Call &call); // doesn’t return until the call is finished
void CanHandleCall (Call &call);
void CannotHandleCall (Call &call);
}
void Employee::ReceiveCall (Call &call) {
free=false;
… // do stuff with the call
}
class Tech : public Employee {
}
class Superadvisor : public Employee {
}
class Voicemail {
public:
void storeMessages(Call &call);
}
class Handler {
private:
int level;
int tech_num;
queue<Call> callqueue;
queue<Tech> techs;
int pos_tech;
Superadvisor ad;
Voicemail v;
public:
Employee AssignCall(Call &call);
void AnwserCall (Call &call);
void AddFreeTech (Employee &em);
}
Employee Handler::AssignCall(Call &call) {
if (!techs.empty()){
Employee em=techs.front();
techs.pop();
return em;
}
if (ad.free) return ad;
return NULL;
}
void Handler::AddFreeTech (Employee &em) {
techs.push(em);
}
void Handler::AnswerCall(Call &call) {
Employee em=AssingCall(call);
if (em!=NULL) {
em.ReceiveCall(call);
}else {
// voice mail box
v.storeMessge(call);
}
}