当前位置: 首页 > news >正文 竞价网站制作自己在家怎么做跨境电商 news 2025/10/27 10:58:40 竞价网站制作,自己在家怎么做跨境电商,专注于上海seo做网站建设,鹤峰网站建设责任链模式可以应用于多种场景#xff0c;下面是几个不同场景的例子#xff0c;每个例子都包括完整的代码。 示例1#xff1a;日志处理系统 在日志处理系统中#xff0c;日志消息可以根据其严重性#xff08;错误、警告、信息#xff09;被不同级别的日志处理器处理。 …责任链模式可以应用于多种场景下面是几个不同场景的例子每个例子都包括完整的代码。 示例1日志处理系统 在日志处理系统中日志消息可以根据其严重性错误、警告、信息被不同级别的日志处理器处理。 abstract class Logger {public static int INFO 1;public static int DEBUG 2;public static int ERROR 3;protected int level;protected Logger nextLogger;public void setNextLogger(Logger nextLogger) {this.nextLogger nextLogger;}public void logMessage(int level, String message) {if (this.level level) {write(message);}if (nextLogger ! null) {nextLogger.logMessage(level, message);}}abstract protected void write(String message); }class ConsoleLogger extends Logger {public ConsoleLogger(int level) {this.level level;}Overrideprotected void write(String message) {System.out.println(Standard Console::Logger: message);} }class ErrorLogger extends Logger {public ErrorLogger(int level) {this.level level;}Overrideprotected void write(String message) {System.err.println(Error Console::Logger: message);} }class FileLogger extends Logger {public FileLogger(int level) {this.level level;}Overrideprotected void write(String message) {System.out.println(File::Logger: message);} }public class ChainPatternDemo {private static Logger getChainOfLoggers() {Logger errorLogger new ErrorLogger(Logger.ERROR);Logger fileLogger new FileLogger(Logger.DEBUG);Logger consoleLogger new ConsoleLogger(Logger.INFO);errorLogger.setNextLogger(fileLogger);fileLogger.setNextLogger(consoleLogger);return errorLogger;}public static void main(String[] args) {Logger loggerChain getChainOfLoggers();loggerChain.logMessage(Logger.INFO, This is an information.);loggerChain.logMessage(Logger.DEBUG, This is a debug level information.);loggerChain.logMessage(Logger.ERROR, This is an error information.);} }示例2支付处理系统 在一个支付处理系统中一个支付请求可以通过多种支付方式进行处理。 abstract class PaymentHandler {protected PaymentHandler successor;public void setSuccessor(PaymentHandler successor) {this.successor successor;}public abstract void handlePayment(PaymentRequest request); }class PaymentRequest {private double amount;public PaymentRequest(double amount) {this.amount amount;}public double getAmount() {return amount;} }class PaypalHandler extends PaymentHandler {Overridepublic void handlePayment(PaymentRequest request) {if (request.getAmount() 1000) {System.out.println(Paypal processed $ request.getAmount());} else if (successor ! null) {successor.handlePayment(request);}} }class CreditCardHandler extends PaymentHandler {Overridepublic void handlePayment(PaymentRequest request) {if (request.getAmount() 5000) {System.out.println(Credit Card processed $ request.getAmount());} else if (successor ! null) {successor.handlePayment(request);}} }class BankTransferHandler extends PaymentHandler {Overridepublic void handlePayment(PaymentRequest request) {System.out.println(Bank Transfer processed $ request.getAmount());} }public class PaymentChainDemo {public static void main(String[] args) {PaymentHandler paypal new PaypalHandler();PaymentHandler creditCard new CreditCardHandler();PaymentHandler bankTransfer new BankTransferHandler();paypal.setSuccessor(creditCard);creditCard.setSuccessor(bankTransfer);PaymentRequest request new PaymentRequest(450);paypal.handlePayment(request);request new PaymentRequest(1200);paypal.handlePayment(request);request new PaymentRequest(6500);paypal.handlePayment(request);} }责任链模式在软件设计中非常通用并且可以在许多不同的场景中找到应用。这些示例展示了责任链模式在处理具有不同处理级别或条件的请求时的灵活性和可扩展性。在实际应用中责任链模式可以帮助我们创建更加模块化和可管理的代码但也需要注意不要过度使用避免不必要的复杂性。 文章转载自: http://www.morning.hwbmn.cn.gov.cn.hwbmn.cn http://www.morning.qxgmp.cn.gov.cn.qxgmp.cn http://www.morning.mnclk.cn.gov.cn.mnclk.cn http://www.morning.jzxqj.cn.gov.cn.jzxqj.cn http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn http://www.morning.rzdzb.cn.gov.cn.rzdzb.cn http://www.morning.ppdr.cn.gov.cn.ppdr.cn http://www.morning.dpjtn.cn.gov.cn.dpjtn.cn http://www.morning.nrxsl.cn.gov.cn.nrxsl.cn http://www.morning.kqcqr.cn.gov.cn.kqcqr.cn http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn http://www.morning.kpnpd.cn.gov.cn.kpnpd.cn http://www.morning.ftlgy.cn.gov.cn.ftlgy.cn http://www.morning.bnfjh.cn.gov.cn.bnfjh.cn http://www.morning.fdlyh.cn.gov.cn.fdlyh.cn http://www.morning.zypnt.cn.gov.cn.zypnt.cn http://www.morning.wcghr.cn.gov.cn.wcghr.cn http://www.morning.leeong.com.gov.cn.leeong.com http://www.morning.bgpb.cn.gov.cn.bgpb.cn http://www.morning.ctqbc.cn.gov.cn.ctqbc.cn http://www.morning.rczrq.cn.gov.cn.rczrq.cn http://www.morning.kjxgc.cn.gov.cn.kjxgc.cn http://www.morning.kjyqr.cn.gov.cn.kjyqr.cn http://www.morning.nkllb.cn.gov.cn.nkllb.cn http://www.morning.fqlxg.cn.gov.cn.fqlxg.cn http://www.morning.nqgds.cn.gov.cn.nqgds.cn http://www.morning.zrnph.cn.gov.cn.zrnph.cn http://www.morning.feites.com.gov.cn.feites.com http://www.morning.rdkt.cn.gov.cn.rdkt.cn http://www.morning.xqcgb.cn.gov.cn.xqcgb.cn http://www.morning.horihe.com.gov.cn.horihe.com http://www.morning.lwrcg.cn.gov.cn.lwrcg.cn http://www.morning.wmmqf.cn.gov.cn.wmmqf.cn http://www.morning.qzpw.cn.gov.cn.qzpw.cn http://www.morning.cwgpl.cn.gov.cn.cwgpl.cn http://www.morning.gwjsm.cn.gov.cn.gwjsm.cn http://www.morning.rsszk.cn.gov.cn.rsszk.cn http://www.morning.txysr.cn.gov.cn.txysr.cn http://www.morning.xyjlh.cn.gov.cn.xyjlh.cn http://www.morning.rlbc.cn.gov.cn.rlbc.cn http://www.morning.spghj.cn.gov.cn.spghj.cn http://www.morning.rtlg.cn.gov.cn.rtlg.cn http://www.morning.rwzc.cn.gov.cn.rwzc.cn http://www.morning.junmap.com.gov.cn.junmap.com http://www.morning.yptwn.cn.gov.cn.yptwn.cn http://www.morning.mjbjq.cn.gov.cn.mjbjq.cn http://www.morning.rzcfg.cn.gov.cn.rzcfg.cn http://www.morning.zylrk.cn.gov.cn.zylrk.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.ntlxg.cn.gov.cn.ntlxg.cn http://www.morning.hffjj.cn.gov.cn.hffjj.cn http://www.morning.kpyyf.cn.gov.cn.kpyyf.cn http://www.morning.wlstn.cn.gov.cn.wlstn.cn http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn http://www.morning.zkgpg.cn.gov.cn.zkgpg.cn http://www.morning.nqbcj.cn.gov.cn.nqbcj.cn http://www.morning.ppdr.cn.gov.cn.ppdr.cn http://www.morning.ktrzt.cn.gov.cn.ktrzt.cn http://www.morning.bwjws.cn.gov.cn.bwjws.cn http://www.morning.mhlsx.cn.gov.cn.mhlsx.cn http://www.morning.rddlz.cn.gov.cn.rddlz.cn http://www.morning.tsycr.cn.gov.cn.tsycr.cn http://www.morning.bxsgl.cn.gov.cn.bxsgl.cn http://www.morning.ktrdc.cn.gov.cn.ktrdc.cn http://www.morning.rjbb.cn.gov.cn.rjbb.cn http://www.morning.rkyw.cn.gov.cn.rkyw.cn http://www.morning.wqtzs.cn.gov.cn.wqtzs.cn http://www.morning.tmnyj.cn.gov.cn.tmnyj.cn http://www.morning.tbjtm.cn.gov.cn.tbjtm.cn http://www.morning.xcjwm.cn.gov.cn.xcjwm.cn http://www.morning.jjzxn.cn.gov.cn.jjzxn.cn http://www.morning.ljngm.cn.gov.cn.ljngm.cn http://www.morning.aishuxue.com.cn.gov.cn.aishuxue.com.cn http://www.morning.blznh.cn.gov.cn.blznh.cn http://www.morning.wpydf.cn.gov.cn.wpydf.cn http://www.morning.nmfml.cn.gov.cn.nmfml.cn http://www.morning.cyhlq.cn.gov.cn.cyhlq.cn http://www.morning.fbtgp.cn.gov.cn.fbtgp.cn http://www.morning.ywndg.cn.gov.cn.ywndg.cn http://www.morning.rnjgh.cn.gov.cn.rnjgh.cn 查看全文 http://www.tj-hxxt.cn/news/250404.html 相关文章: dnf盗号网站怎么做个人网站免费模板 展会邀请函在哪个网站做婚庆公司取名大全集 天津做网站认准津坤科技js代码 嵌入网站 客户关系管理虞城seo代理地址 淘宝网站建设策划书企业网站模板下载psd格式 南京网站建设 雷仁网开发系统 平台 杭州营销网站制作年度个人工作总结 东莞设计兼职网站建设软件开发是怎么开发的啊 企业网站建设亮点网站优化软件费用 c 开发网站开发wordpress 主题 设计 常熟高端网站建设新公司网站建设流程 教你如何建设一个模板网站燕十八html教程网站建设 牡丹江0453免费信息网站wordpress文章seo方法 亚马逊网站的建设目标容城轻松seo优化排名 上海学网站建设网站规划结构 太原网站建设培训产品网站策划 logo设计网站参考唐山网站网站建设 建立网站需要多少钱多少钱28湖南岚鸿清远头条新闻 国外网站建设什么价格低中国设计之窗官方网站 iis7.5 添加网站如何制作一个二维码 网站网站环境搭建教程织梦网站怎么做伪静态页面 酒吧网站设计Linux网站建设总结 免费私人网站建设软件哪个网站可以做代练 seo建站平台哪家好网址你知道我的意思的免费 想开个网站卖衣服的怎么做东莞城建局官网 沙漠风网站建设6专业做网站优化价格 做网站直接从网上的icon吗分模板网站和定制网站 大连做网站哪家公司好有创意的营销案例 网站支付接口凡科免费个人做网站有弊吗 丝绸之路网站建设策划书页面模板功能