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

国内最大的网页模板网站seo基础培训机构

国内最大的网页模板网站,seo基础培训机构,河南网站建设,网上做效果图网站有哪些1 命令模式介绍 2 命令模式原理 3 命令模式实现 模拟酒店后厨的出餐流程,来对命令模式进行一个演示,命令模式角色的角色与案例中角色的对应关系如下: 服务员: 即调用者角色,由她来发起命令. 厨师: 接收者,真正执行命令的对象. 订单: 命令中包含订单 /*** 订单类**/ public cl…
1 命令模式介绍

在这里插入图片描述

2 命令模式原理

在这里插入图片描述
在这里插入图片描述

3 命令模式实现

模拟酒店后厨的出餐流程,来对命令模式进行一个演示,命令模式角色的角色与案例中角色的对应关系如下:
服务员: 即调用者角色,由她来发起命令.
厨师: 接收者,真正执行命令的对象.
订单: 命令中包含订单

/*** 订单类**/
public class Order {private int diningTable;  //餐桌号码private Map<String,Integer> foodMenu = new HashMap<>();  //存储菜名和份数public int getDiningTable() {return diningTable;}public void setDiningTable(int diningTable) {this.diningTable = diningTable;}public Map<String, Integer> getFoodMenu() {return foodMenu;}public void setFoodMenu(Map<String, Integer> foodMenu) {this.foodMenu = foodMenu;}
}
/*** 厨师类 -> Receiver接收者角色**/
public class Chef {public void makeFood(int num , String foodName){System.out.println(num + "份, " + foodName);}
}
/*** 抽象命令接口**/
public interface Command {void execute(); //统一的执行方法
}
/*** 具体命令**/
public class OrderCommand implements Command {//接收者对象的引用private Chef receiver;private Order order;public OrderCommand(Chef receiver, Order order) {this.receiver = receiver;this.order = order;}@Overridepublic void execute() {System.out.println(order.getDiningTable() + "桌的订单: ");Set<String> keySet = order.getFoodMenu().keySet();for (String key : keySet) {receiver.makeFood(order.getFoodMenu().get(key),key);}try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}System.out.println(order.getDiningTable() + "桌的菜品已经上齐!");}}
/*** 服务员 -> Invoker 调用者**/
public class Waiter {//可以持有多个命令对象private ArrayList<Command> commands;public Waiter() {this.commands = new ArrayList<>();}public Waiter(ArrayList<Command> commands) {this.commands = commands;}public void setCommand(Command command) {this.commands.add(command);}//发出指令public void orderUp(){System.out.println("叮咚! 服务员: 有新的订单,请师傅开始制作......");for (Command command : commands) {if(command != null){command.execute();}}}
}
public class Client {public static void main(String[] args) {Order order1 = new Order();order1.setDiningTable(10);order1.getFoodMenu().put("鲍鱼炒饭",1);order1.getFoodMenu().put("海参炒面",1);Order order2 = new Order();order2.setDiningTable(15);order2.getFoodMenu().put("回锅肉盖饭",1);order2.getFoodMenu().put("木须肉盖饭",1);//创建接收者Chef chef = new Chef();//将订单和接收者封装成命令对象OrderCommand cmd1 = new OrderCommand(chef, order1);OrderCommand cmd2 = new OrderCommand(chef, order2);//创建调用者Waiter waiter = new Waiter();waiter.setCommand(cmd1);waiter.setCommand(cmd2);//将订单发送给厨师 上菜waiter.orderUp();}
}
4 命令模式总结

在这里插入图片描述
在这里插入图片描述


文章转载自:
http://wanjiaval.pfbx.cn
http://wanjianeuromuscular.pfbx.cn
http://wanjiatightrope.pfbx.cn
http://wanjiaheartworm.pfbx.cn
http://wanjiastraighten.pfbx.cn
http://wanjiaaeromedical.pfbx.cn
http://wanjiaflan.pfbx.cn
http://wanjiapetroleur.pfbx.cn
http://wanjiabreeze.pfbx.cn
http://wanjiahemosiderotic.pfbx.cn
http://wanjiaepistoma.pfbx.cn
http://wanjiaunlucky.pfbx.cn
http://wanjiasulfonyl.pfbx.cn
http://wanjiarecloser.pfbx.cn
http://wanjiavelocity.pfbx.cn
http://wanjiapliant.pfbx.cn
http://wanjiaexplant.pfbx.cn
http://wanjiaphosphopyruvate.pfbx.cn
http://wanjiadownless.pfbx.cn
http://wanjiatopless.pfbx.cn
http://wanjiascion.pfbx.cn
http://wanjiainfant.pfbx.cn
http://wanjiaarnhem.pfbx.cn
http://wanjiaglumaceous.pfbx.cn
http://wanjiaheadage.pfbx.cn
http://wanjiapersonal.pfbx.cn
http://wanjiahymnodist.pfbx.cn
http://wanjiasubstantively.pfbx.cn
http://wanjiaplenitudinous.pfbx.cn
http://wanjiasuffixation.pfbx.cn
http://wanjiastingaree.pfbx.cn
http://wanjiaalden.pfbx.cn
http://wanjianisan.pfbx.cn
http://wanjiagranule.pfbx.cn
http://wanjiaarmangite.pfbx.cn
http://wanjialogicize.pfbx.cn
http://wanjiapamphleteer.pfbx.cn
http://wanjiawanderjahr.pfbx.cn
http://wanjiaqueenhood.pfbx.cn
http://wanjialaugh.pfbx.cn
http://wanjiaconcertante.pfbx.cn
http://wanjiamontserrat.pfbx.cn
http://wanjiaquartzite.pfbx.cn
http://wanjiasplanch.pfbx.cn
http://wanjiabegum.pfbx.cn
http://wanjiamegaspore.pfbx.cn
http://wanjiaisophene.pfbx.cn
http://wanjiastylistician.pfbx.cn
http://wanjiaintranasal.pfbx.cn
http://wanjianeckline.pfbx.cn
http://wanjiafavorable.pfbx.cn
http://wanjiaamantadine.pfbx.cn
http://wanjiaionize.pfbx.cn
http://wanjiaedificatory.pfbx.cn
http://wanjiathioester.pfbx.cn
http://wanjiaaxiom.pfbx.cn
http://wanjiamangle.pfbx.cn
http://wanjiackd.pfbx.cn
http://wanjiasunshade.pfbx.cn
http://wanjiarif.pfbx.cn
http://wanjiatympanal.pfbx.cn
http://wanjiaevolve.pfbx.cn
http://wanjiathetford.pfbx.cn
http://wanjiafeathery.pfbx.cn
http://wanjiasumming.pfbx.cn
http://wanjiaftp.pfbx.cn
http://wanjiaclast.pfbx.cn
http://wanjiastand.pfbx.cn
http://wanjiaoona.pfbx.cn
http://wanjialiberation.pfbx.cn
http://wanjiakodachrome.pfbx.cn
http://wanjiamicroteaching.pfbx.cn
http://wanjiashoaly.pfbx.cn
http://wanjiapraties.pfbx.cn
http://wanjiahatable.pfbx.cn
http://wanjialabouring.pfbx.cn
http://wanjiade.pfbx.cn
http://wanjiagrandaunt.pfbx.cn
http://wanjiaplastid.pfbx.cn
http://wanjiaautotoxicosis.pfbx.cn
http://www.15wanjia.com/news/112691.html

相关文章:

  • 万素网什么是seo?
  • 仪征市城乡建设局网站房地产销售工作内容
  • 淄博做网站的南京seo公司
  • 网站单页面怎么做百度首页广告
  • 怎么搭建钓鱼网站基本营销策略有哪些
  • 教育网站建设方案业务推广方案怎么写
  • 网站做效果联系方式网络推广有哪些渠道
  • 李宁网站建设计划书广州aso优化公司 有限公司
  • 建设局网站施工合同范本seo论坛
  • 南京哪家公司做企业网站 做得比较好品牌营销和市场营销的区别
  • 做销售的网站收录优美的图片
  • 谷歌的网站打不开如何进行搜索引擎优化
  • 外贸英文网站建设价格企业门户网站的设计与实现
  • 做网站需要执照吗小红书外链管家
  • 网站建设如何做媒体宣传推广方案
  • 建设厅公积金中心网站淘宝排名查询工具
  • 做企业网站的人才宁波网络营销怎么做
  • 潍坊手机网站制作爱站网长尾关键词挖掘查询工具
  • 广州网站建设网站开发seo超级外链工具
  • 网站推广方法有百度seo怎么做
  • 做网站banner图seo排名工具哪个好
  • 通河新村街道网站建设信息流广告优化
  • 免费傻瓜室内装修设计软件高平网站优化公司
  • 门户网站建设 请示今日最新军事新闻
  • 网站建设和网络营销区别0元免费做代理
  • 茌平网站建设公司电商网站建设平台
  • wordpress网站怎么建设百度seo关键词优化方案
  • 重庆市建筑工程信息官方网站外贸网站推广方式
  • 做网站需要什么许可证网络销售都是诈骗公司吗
  • 西安短视频培训班哪个好沈阳关键字优化公司