标签:
public class CallHandler{
private static CallHandler instance;
/*
三个员工层级:接线员,主管,经理
*/
private final int LEVELS=3;
/*
起始设定10位接线员,4位主管和2位经理
*/
private final int NUM_RESPONDENTS=10;
private final int NUM_MANAGERS=4;
private final int NUM_DIRECTORS=2;
/*
员工列表,以层级区分
employeeLevels[0]=接线员;
employeeLevels[1]=主管;
employeeLevels[2]=经理;
*/
List<List<Employee>> employeeLevels;
/*存放来电层级的队列*/
List<List<Call>> callQueues;
protected CallHandler(){...}
/*取得单态类的实例*/
public static CallHandler getInstance()
{
if(instance == null) instance=new CallHandler();
return instance;
}
/*找出第一个有空处理来电的员工*/
public Employee getHandlerForCall(Call call){...}
/*将来电分派给有空的员工,若没人有空,就存放在队列中*/
public void dispatchCall(Caller caller)
{
Call call=new Call(caller);
dispatchCall(call);
}
/*将来电分配给有空的员工,若没人有空,就存放在队列中
*/
public void dispatchCall(Call call)
{
//试着将来电分派给层级最低的员工
Employee emp=getHandlerForCall(call);
if(emp!=null)
{
emp.receiveCall(call);
call.setHandler(emp);
}
else
{
/*根据来电级别,将来电放到相应的队列中*/
call.reply("Please wait for free employee to reply");
callQueues[call.getRank().getValue()].add(call);
}
}
//有员工有空了,查找该员工可服务的来电,若分派了来电,则返回true,否则返回false
public boolean assignCall(Employee emp){....}
}
Call 代表客户来电,每次来电有个最低层级,并且会被分派给第一个可处理该来电的员工。
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/wangfengfan1/article/details/48010721