1700464107
public Handler(int_level){
1700464108
1700464109
this.level=_level;
1700464110
1700464111
}
1700464112
1700464113
//一个女性(女儿、妻子或者是母亲)要求逛街,你要处理这个请求
1700464114
1700464115
public final void HandleMessage(IWomen women){
1700464116
1700464117
if(women.getType()==this.level){
1700464118
1700464119
this.response(women);
1700464120
1700464121
}else{
1700464122
1700464123
if(this.nextHandler!=null){//有后续环节,才把请求往后递送
1700464124
1700464125
this.nextHandler.HandleMessage(women);
1700464126
1700464127
}else{//已经没有后续处理人了,不用处理了
1700464128
1700464129
System.out.println(”–没地方请示了,按不同意处理–\n”);
1700464130
1700464131
}
1700464132
1700464133
}
1700464134
1700464135
}
1700464136
1700464137
/*
1700464138
1700464139
*如果不属于你处理的请求,你应该让她找下一个环节的人,如女儿出嫁了,
1700464140
1700464141
*还向父亲请示是否可以逛街,那父亲就应该告诉女儿,应该找丈夫请示
1700464142
1700464143
*/
1700464144
1700464145
public void setNext(Handler_handler){
1700464146
1700464147
this.nextHandler=_handler;
1700464148
1700464149
}
1700464150
1700464151
//有请示那当然要回应
1700464152
1700464153
protected abstract void response(IWomen women);
1700464154
1700464155
}
1700464156
[
上一页 ]
[ :1.700464107e+09 ]
[
下一页 ]