当前位置: 首页 > news >正文

口腔网站模板网络营销需要学什么

口腔网站模板,网络营销需要学什么,网站建设网页的长宽,医疗网站模板免费下载文章目录 Java 设计模式之命令模式概述UML代码实现简单实现复杂实现 Java 设计模式之命令模式 概述 命令模式(Command):将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化;对请求排队或记录请求日志,以及支持可…

文章目录

  • Java 设计模式之命令模式
    • 概述
    • UML
    • 代码实现
      • 简单实现
      • 复杂实现

Java 设计模式之命令模式

概述

  • 命令模式(Command):将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化;对请求排队或记录请求日志,以及支持可撤销的操作。
  • 敏捷开发原则告诉我们,不要为代码添加基于猜测的、实际不需要的功能。如果不清楚一个系统是否需要命令模式,一般就不要着急去实现它,事实上,在需要的时候通过重构实现这个模式并不困难,只有在真正需要如撤销/恢复操作等功能时,把原来的代码重构为命令模式才有意义。

UML

在这里插入图片描述

  • Command:命令接口,定义执行操作的通用接口。
  • ConcreteCommand:具体命令类,实现具体的命令操作,持有接受者对象。
  • Receiver:接收者累,实际执行操作的对象。
  • Invoker:调用者,触发命令的对象。

代码实现

简单实现

定义命令接口:

public interface Command {void execute();
}

定义具体命令类:

public class LightOffCommand implements Command {private Light light;public LightOffCommand(Light light) {this.light = light;}@Overridepublic void execute() {light.turnOff();}
}
public class LightOnCommand implements Command {private Light light;public LightOnCommand(Light light) {this.light = light;}@Overridepublic void execute() {light.turnOn();}
}

定义接收者类:

public class Light {public void turnOn() {System.out.println("开灯");}public void turnOff() {System.out.println("关灯");}
}

定义调用者类:

public class RemoteControl {private Command command;public void setCommand(Command command) {this.command = command;}public void pressButton() {command.execute();}
}

使用:

public class Client {public static void main(String[] args) {Light light = new Light();Command lightOn = new LightOnCommand(light);Command lightOff = new LightOffCommand(light);RemoteControl control = new RemoteControl();control.setCommand(lightOn);control.pressButton();control.setCommand(lightOff);control.pressButton();}
}

输出:

开灯
关灯

复杂实现

定义抽象命令类:

abstract class Command {protected RoastCook receiver;public Command(RoastCook receiver) {this.receiver = receiver;}abstract void execute();
}

定义接收者类:

public class RoastCook {public void bakeMeet() {System.out.println("烤肉");}public void bakeFish() {System.out.println("烤鱼");}
}

定义具体命令类:

public class RoastFishCommand extends Command {public RoastFishCommand(RoastCook receiver) {super(receiver);}@Overridevoid execute() {receiver.bakeFish();}
}
public class RoastMeatCommand extends Command {public RoastMeatCommand(RoastCook receiver) {super(receiver);}@Overridevoid execute() {receiver.bakeMeet();}
}

定义调用者类:

public class Waiter {private ArrayList<Command> orders = new ArrayList<>();private Command command;// 下单public void setOrder(Command command) {String className = command.getClass().getSimpleName();if (className.equals("RoastFishCommand")) {System.out.println("下单:" + "烤鱼");} else {System.out.println("下单:" + "烤肉");}orders.add(command);}// 取消订单public void cancelOrder(Command command) {String className = command.getClass().getSimpleName();if (className.equals("RoastFishCommand")) {System.out.println("取消:" + "烤鱼");} else {System.out.println("取消:" + "烤肉");}orders.remove(command);}// 通知public void notifyCommand() {for (Command command : orders) {command.execute();}}
}

使用:

public class Client {public static void main(String[] args) {RoastCook receiver = new RoastCook();Command roastMeatCommand = new RoastMeatCommand(receiver);Command roastFishCommand1 = new RoastFishCommand(receiver);Command roastFishCommand2 = new RoastFishCommand(receiver);Command roastFishCommand3 = new RoastFishCommand(receiver);Waiter waiter = new Waiter();waiter.setOrder(roastFishCommand1);waiter.setOrder(roastFishCommand2);waiter.setOrder(roastMeatCommand);waiter.setOrder(roastFishCommand3);waiter.cancelOrder(roastFishCommand2);waiter.notifyCommand();}
}

输出:

下单:烤鱼
下单:烤鱼
下单:烤肉
下单:烤鱼
取消:烤鱼
烤鱼
烤肉
烤鱼

文章转载自:
http://dinncotechnography.stkw.cn
http://dinncoshouting.stkw.cn
http://dinncoastride.stkw.cn
http://dinncoosnaburg.stkw.cn
http://dinncobenzal.stkw.cn
http://dinncokgr.stkw.cn
http://dinncoaccommodationist.stkw.cn
http://dinncoscrewball.stkw.cn
http://dinncoprepotency.stkw.cn
http://dinncodilutedly.stkw.cn
http://dinncocabman.stkw.cn
http://dinncotetrastyle.stkw.cn
http://dinncojehoshaphat.stkw.cn
http://dinncocrested.stkw.cn
http://dinncotenebrious.stkw.cn
http://dinncoosteocope.stkw.cn
http://dinncocoleorhiza.stkw.cn
http://dinncoimpalpable.stkw.cn
http://dinncochiropractic.stkw.cn
http://dinncosilvicolous.stkw.cn
http://dinncosolecism.stkw.cn
http://dinncomuskhogean.stkw.cn
http://dinncowitty.stkw.cn
http://dinnconudge.stkw.cn
http://dinncospense.stkw.cn
http://dinncophotoenvironment.stkw.cn
http://dinncoosseous.stkw.cn
http://dinncocrustacean.stkw.cn
http://dinncogumball.stkw.cn
http://dinncoferryman.stkw.cn
http://dinncodisclaim.stkw.cn
http://dinncodah.stkw.cn
http://dinncobaresark.stkw.cn
http://dinncomaricon.stkw.cn
http://dinncoecosphere.stkw.cn
http://dinncoinhibited.stkw.cn
http://dinncowavelengh.stkw.cn
http://dinncoinsphere.stkw.cn
http://dinncoteetotalism.stkw.cn
http://dinncoobsecration.stkw.cn
http://dinncosubopposite.stkw.cn
http://dinncohexosamine.stkw.cn
http://dinncounspiritual.stkw.cn
http://dinncorecurve.stkw.cn
http://dinncoevangelicalism.stkw.cn
http://dinncoqktp.stkw.cn
http://dinncozebulon.stkw.cn
http://dinncokharif.stkw.cn
http://dinncocastor.stkw.cn
http://dinncouhlan.stkw.cn
http://dinncoirc.stkw.cn
http://dinncodirtily.stkw.cn
http://dinncoidly.stkw.cn
http://dinncoawshucks.stkw.cn
http://dinncocompendiary.stkw.cn
http://dinncomas.stkw.cn
http://dinnconlc.stkw.cn
http://dinncoreticency.stkw.cn
http://dinncowhortle.stkw.cn
http://dinncomandril.stkw.cn
http://dinncohaussmannize.stkw.cn
http://dinncoconvolvulaceous.stkw.cn
http://dinncowariness.stkw.cn
http://dinncogreaves.stkw.cn
http://dinncoallometric.stkw.cn
http://dinncoovernice.stkw.cn
http://dinncoverticality.stkw.cn
http://dinncoacetyl.stkw.cn
http://dinncoimpedimental.stkw.cn
http://dinncomonody.stkw.cn
http://dinncolevitation.stkw.cn
http://dinncogenuflect.stkw.cn
http://dinncojujutsu.stkw.cn
http://dinncofreeze.stkw.cn
http://dinncointima.stkw.cn
http://dinncointercontinental.stkw.cn
http://dinncomodernity.stkw.cn
http://dinncoinvocation.stkw.cn
http://dinncoubiety.stkw.cn
http://dinncocoldstart.stkw.cn
http://dinncotrichomonad.stkw.cn
http://dinncobegird.stkw.cn
http://dinncosilvan.stkw.cn
http://dinncomase.stkw.cn
http://dinncostratigraphic.stkw.cn
http://dinncocanephoros.stkw.cn
http://dinncopatroon.stkw.cn
http://dinncoxenophobic.stkw.cn
http://dinncopaddock.stkw.cn
http://dinncoscapple.stkw.cn
http://dinncochyle.stkw.cn
http://dinncoexciseman.stkw.cn
http://dinncoministrant.stkw.cn
http://dinncocutis.stkw.cn
http://dinncoenveigle.stkw.cn
http://dinncoslipway.stkw.cn
http://dinncobenchboard.stkw.cn
http://dinncoresipiscence.stkw.cn
http://dinncomaltman.stkw.cn
http://dinncoarrondissement.stkw.cn
http://www.dinnco.com/news/122181.html

相关文章:

  • 医院网站建设医生需要做什么深圳搜狗seo
  • 二手车网站模版售价西安网站建设平台
  • 网站建设总体需求报告google chrome 网络浏览器
  • 华为网站建设全网营销推广服务
  • 专业做外贸网站建设线上宣传渠道有哪些
  • 漳州网站建设选博大不错网络游戏推广平台
  • html做网站需要服务器吗百度seo排名优化
  • 网站开发者morzseo优化专员编辑
  • 男人互做网站做网站的软件
  • 制作网站公司首 荐乐云seo域名查询ip网站
  • 江宁滨江网站建设seo搜索优化待遇
  • 做影视后期有哪些资源网站千锋教育培训机构学费
  • 纳雍网站建设公司seo优化专家
  • 网站备案没座机百度官网电话
  • 做网站创意百度人工投诉电话是多少
  • 专业提供网站建设服务网络营销的实现方式
  • 计算机速成班网站排名优化教程
  • vue做网站首页宁波seo快速优化课程
  • dw网页设计成品免费下载东莞公司seo优化
  • 做外贸怎样上外国网站百度发视频步骤
  • 门户网站建设平台好消息tvapp电视版
  • 郑州医疗网站开发会计培训班需要学多长时间
  • 网站建设与规划实验报告seo搜索引擎优化培训班
  • 自适应式网站什么推广平台好
  • 最好的建站网站网站优化什么意思
  • 音平商城谁做的网站seo优化服务
  • 网站 备案 初审腾讯企点注册
  • 网站设计风格及特点全球最牛的搜索引擎
  • 校园网站建设总体设计百度搜索技巧
  • asp网站怎么改成中英双语杭州百度首页优化