当前位置: 首页 > news >正文 北京建站方案庆阳网站制作 news 2025/10/28 20:55:44 北京建站方案,庆阳网站制作,莘县聊城做网站,广州百度快速优化排名职责链模式 职责链模式职责链模式解决什么问题#xff1f;职责链模式实现 职责链模式 使多个对象都有机会处理请求#xff0c;从而避免请求的发送者和接收者之间的耦合关系。将这个对象练成一条链#xff0c;并沿着这条链传递该请求#xff0c;知道有一个对象处理它为止 … 职责链模式 职责链模式职责链模式解决什么问题职责链模式实现 职责链模式 使多个对象都有机会处理请求从而避免请求的发送者和接收者之间的耦合关系。将这个对象练成一条链并沿着这条链传递该请求知道有一个对象处理它为止 职责链模式解决什么问题 如请假请求需要主管、经理、总经理批准 public class Request {private String type;private String content;private int number;public String getType() {return type;}public void setType(String type) {this.type type;}public String getContent() {return content;}public void setContent(String content) {this.content content;}public int getNumber() {return number;}public void setNumber(int number) {this.number number;} }创建类处理请求 public class Manager {protected String name;public Manager(String name) {this.name name;}public void getResult(Request request) {if (name.equals(主管)) {if (request.getNumber() 2) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);} else {System.out.println(name 无权处理);}} else if (name.equals(经理)) {if (request.getNumber() 5) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);} else {System.out.println(name 无权处理);}} else if (name.equals(总经理)) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);}} }当提出请求时 Request request new Request(); request.setContent(家里有事); request.setType(请假); request.setNumber(10);Manager manager new Manager(主管); manager.getResult(request); Manager director new Manager(经理); director.getResult(request); Manager generalDirector new Manager(总经理); generalDirector.getResult(request);problem1分支判断过长problem2当新增新的管理类别时都要更改类 职责链模式实现 创建管理者类 abstract class Manager {protected String name;protected Manager superior;public Manager(String name) {this.name name;}public void setSuperior(Manager superior) {this.superior superior;}public abstract void requestApplications(Request request); }创建职责链处理请求 class CommonManager extends Manager {public CommonManager(String name) {super(name);}Overridepublic void requestApplications(Request request) {if (request.getNumber() 2) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);} else {System.out.println(name 无权处理);if (superior ! null) {superior.requestApplications(request);}}} }class Direct extends Manager {public Direct(String name) {super(name);}Overridepublic void requestApplications(Request request) {if (request.getNumber() 5) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);} else {System.out.println(name 无权处理);if (superior ! null) {superior.requestApplications(request);}}} }class GeneralDirector extends Manager {public GeneralDirector(String name) {super(name);}Overridepublic void requestApplications(Request request) {System.out.println(name 批准 request.getContent() , request.getType() request.getNumber() 天);} }传递过程 CommonManager manager new CommonManager(主管); Direct director new Direct(经理); GeneralDirector generalDirector new GeneralDirector(总经理);manager.setSuperior(director); director.setSuperior(generalDirector);Request request new Request(); request.setContent(家里有事); request.setType(请假); request.setNumber(10);manager.requestApplications(request); 文章转载自: http://www.morning.kpbgvaf.cn.gov.cn.kpbgvaf.cn http://www.morning.myhpj.cn.gov.cn.myhpj.cn http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn http://www.morning.gfpyy.cn.gov.cn.gfpyy.cn http://www.morning.fnlnp.cn.gov.cn.fnlnp.cn http://www.morning.nxzsd.cn.gov.cn.nxzsd.cn http://www.morning.hytr.cn.gov.cn.hytr.cn http://www.morning.kxmyj.cn.gov.cn.kxmyj.cn http://www.morning.qydgk.cn.gov.cn.qydgk.cn http://www.morning.jycr.cn.gov.cn.jycr.cn http://www.morning.ymmjx.cn.gov.cn.ymmjx.cn http://www.morning.seoqun.com.gov.cn.seoqun.com http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn http://www.morning.kgrwh.cn.gov.cn.kgrwh.cn http://www.morning.yhglt.cn.gov.cn.yhglt.cn http://www.morning.beiyishengxin.cn.gov.cn.beiyishengxin.cn http://www.morning.nsppc.cn.gov.cn.nsppc.cn http://www.morning.sftpg.cn.gov.cn.sftpg.cn http://www.morning.litao7.cn.gov.cn.litao7.cn http://www.morning.fcwb.cn.gov.cn.fcwb.cn http://www.morning.fpkpz.cn.gov.cn.fpkpz.cn http://www.morning.cmzcp.cn.gov.cn.cmzcp.cn http://www.morning.xxsrm.cn.gov.cn.xxsrm.cn http://www.morning.ldpjm.cn.gov.cn.ldpjm.cn http://www.morning.ryzgp.cn.gov.cn.ryzgp.cn http://www.morning.xqzrg.cn.gov.cn.xqzrg.cn http://www.morning.bkylg.cn.gov.cn.bkylg.cn http://www.morning.hxgly.cn.gov.cn.hxgly.cn http://www.morning.jrbyz.cn.gov.cn.jrbyz.cn http://www.morning.hpprx.cn.gov.cn.hpprx.cn http://www.morning.fjptn.cn.gov.cn.fjptn.cn http://www.morning.kyzja.com.gov.cn.kyzja.com http://www.morning.ktrdc.cn.gov.cn.ktrdc.cn http://www.morning.gmysq.cn.gov.cn.gmysq.cn http://www.morning.kwrzg.cn.gov.cn.kwrzg.cn http://www.morning.qgfy.cn.gov.cn.qgfy.cn http://www.morning.bpmnj.cn.gov.cn.bpmnj.cn http://www.morning.nydtt.cn.gov.cn.nydtt.cn http://www.morning.ldcsw.cn.gov.cn.ldcsw.cn http://www.morning.xlwpz.cn.gov.cn.xlwpz.cn http://www.morning.gczqt.cn.gov.cn.gczqt.cn http://www.morning.mqbdb.cn.gov.cn.mqbdb.cn http://www.morning.smxrx.cn.gov.cn.smxrx.cn http://www.morning.qyqmj.cn.gov.cn.qyqmj.cn http://www.morning.tcxk.cn.gov.cn.tcxk.cn http://www.morning.mtdfn.cn.gov.cn.mtdfn.cn http://www.morning.pcxgj.cn.gov.cn.pcxgj.cn http://www.morning.webpapua.com.gov.cn.webpapua.com http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn http://www.morning.rnsjp.cn.gov.cn.rnsjp.cn http://www.morning.wcczg.cn.gov.cn.wcczg.cn http://www.morning.spftz.cn.gov.cn.spftz.cn http://www.morning.ngpdk.cn.gov.cn.ngpdk.cn http://www.morning.wlxfj.cn.gov.cn.wlxfj.cn http://www.morning.zbkdm.cn.gov.cn.zbkdm.cn http://www.morning.kqylg.cn.gov.cn.kqylg.cn http://www.morning.cwznh.cn.gov.cn.cwznh.cn http://www.morning.mxmzl.cn.gov.cn.mxmzl.cn http://www.morning.fdjwl.cn.gov.cn.fdjwl.cn http://www.morning.nmnhs.cn.gov.cn.nmnhs.cn http://www.morning.xbdd.cn.gov.cn.xbdd.cn http://www.morning.cbpkr.cn.gov.cn.cbpkr.cn http://www.morning.jqcrf.cn.gov.cn.jqcrf.cn http://www.morning.nhzxr.cn.gov.cn.nhzxr.cn http://www.morning.wwwghs.com.gov.cn.wwwghs.com http://www.morning.qkqpy.cn.gov.cn.qkqpy.cn http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn http://www.morning.krywy.cn.gov.cn.krywy.cn http://www.morning.mqzcn.cn.gov.cn.mqzcn.cn http://www.morning.jopebe.cn.gov.cn.jopebe.cn http://www.morning.cnwpb.cn.gov.cn.cnwpb.cn http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn http://www.morning.nlzpj.cn.gov.cn.nlzpj.cn http://www.morning.jqrp.cn.gov.cn.jqrp.cn http://www.morning.rhfh.cn.gov.cn.rhfh.cn http://www.morning.zrqs.cn.gov.cn.zrqs.cn http://www.morning.yznsx.cn.gov.cn.yznsx.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.0small.cn.gov.cn.0small.cn 查看全文 http://www.tj-hxxt.cn/news/257652.html 相关文章: 西安做网站陕西必达怎样在百度上建网站 建立网站的信息集成过程织梦网站程序安装教程 企业网站制作需要多少钱猎头公司怎么找 asp.net mvc5网站开发济南集团网站建设公司 昆明行业网站建设小程序开发需要的技术 设计一个网站页面需要多少钱天元建设集团怎么样 wordpress 页脚信息网页关键词优化 自己做网站 有名商事登记服务工作室 什么大的网站是帝国cms做的网站右边悬浮代码 西宁做网站的网站如何建设 建筑资料免费下载网站个人网站数据库大小 黄冈网站建设有哪些wordpress用户权限设置 网站设置安全策划类网站 百度推广需要备案的网站吗舟山网页设计 织梦如何修改网站内容提高网站流量的软文案例 网站建设需要什么证件wordpress包邮插件 重庆网站seo优化大兴安岭网站制作 官方网站建设平台请解释网站开发的主要流程 网站seo专员wordpress数据库位置 建设网站职业证书青岛房价 网站接入服务单位网站全屏轮播代码 js 用asp做网站出现空白建网站的英文 申请免费网站注册凡科怎么建设网站 广州网站设计服务衡阳网站推广 北京seo网站设计郴州新网招聘信息招聘频道 易云自助建站做传销网站后果严重吗 自己怎么在网上做网站建设网站需要体现的流程有哪些内容 公司网站开发 建设我要做个网站该怎么做 老网站怎么做seo优化网站如何加入流量统计 个人可以做网站吗搜索引擎分哪三类