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

营销型网站建设和平台建设做项目的招聘网站

营销型网站建设和平台建设,做项目的招聘网站,制作微信小程序步骤,wordpress get page前言#xff1a;【模式总览】——————————by xingoo 模式意图 使用一个中介的对象#xff0c;封装一组对象之间的交互#xff0c;这样这些对象就可以不用彼此耦合。 这个中介者常常起着中间桥梁的作用#xff0c;使其他的对象可以利用中介者完成某些行为活动#…  前言【模式总览】——————————by xingoo   模式意图   使用一个中介的对象封装一组对象之间的交互这样这些对象就可以不用彼此耦合。   这个中介者常常起着中间桥梁的作用使其他的对象可以利用中介者完成某些行为活动因此它必须对所有的参与活动的对象了如指掌   应用场景   1 当一组对象要进行沟通或者业务上的交互但是其关系却又很复杂混乱时可以采用此模式。   2 当一个对象与其他的对象要进行紧密的交互但又想服用该对象而不依赖其他的对象时。   3 想创造一个运行于多个类之间的对象又不想生成新的子类时。   模式结构      Mediator 抽象的中介者定义中介的规范 interface Mediator{public void colleagueChanged(Colleague c); }   ConcreteMediator 具体的中介者通常内部依赖于多个业务对象 class ConcreteMediator implements Mediator{private Colleague1 col1;private Colleague2 col2;public void colleagueChanged(Colleague c) {col1.action();col2.action();}public void createConcreteMediator() {col1 new Colleague1(this);col2 new Colleague2(this);}private Colleague1 getCol1() {return col1;}public Colleague2 getCol2() {return col2;} }   Colleague 抽象的业务角色 abstract class Colleague{private Mediator mediator;public Colleague(Mediator mediator){this.mediator mediator;}public Mediator getMediator() {return mediator;}public abstract void action();public void change(){mediator.colleagueChanged(this);} }   Colleague1 Colleague2 具体的业务角色 class Colleague1 extends Colleague{public Colleague1(Mediator m){super(m);}public void action(){System.out.println(this is an action from Colleague1);} } class Colleague2 extends Colleague{public Colleague2(Mediator m){super(m);}public void action(){System.out.println(this is an action from Colleague2);} }   全部代码 1 package com.xingoo.test.design.mediator;2 abstract class Colleague{3 private Mediator mediator;4 5 public Colleague(Mediator mediator){6 this.mediator mediator;7 }8 9 public Mediator getMediator() { 10 return mediator; 11 } 12 13 public abstract void action(); 14 15 public void change(){ 16 mediator.colleagueChanged(this); 17 } 18 } 19 class Colleague1 extends Colleague{ 20 public Colleague1(Mediator m){ 21 super(m); 22 } 23 public void action(){ 24 System.out.println(this is an action from Colleague1); 25 } 26 } 27 class Colleague2 extends Colleague{ 28 public Colleague2(Mediator m){ 29 super(m); 30 } 31 public void action(){ 32 System.out.println(this is an action from Colleague2); 33 } 34 } 35 interface Mediator{ 36 public void colleagueChanged(Colleague c); 37 } 38 class ConcreteMediator implements Mediator{ 39 private Colleague1 col1; 40 private Colleague2 col2; 41 42 public void colleagueChanged(Colleague c) { 43 col1.action(); 44 col2.action(); 45 } 46 47 public void createConcreteMediator() { 48 col1 new Colleague1(this); 49 col2 new Colleague2(this); 50 } 51 52 private Colleague1 getCol1() { 53 return col1; 54 } 55 56 public Colleague2 getCol2() { 57 return col2; 58 } 59 60 } 61 62 public class Client { 63 public static void main(String[] args) { 64 ConcreteMediator mediator new ConcreteMediator(); 65 mediator.createConcreteMediator(); 66 Colleague1 col1 new Colleague1(mediator); 67 // Colleague2 col2 new Colleague2(mediator); 68 mediator.colleagueChanged(col1); 69 } 70 } View Code   运行结果 this is an action from Colleague1 this is an action from Colleague2     生活中的设计模式        毕业的同学们第一个要解决的问题就是租房子当白富美高富帅出没社会后穷屌丝没了生存之地。但是只要勤劳一样有饭吃有房住   这里房屋中介好比是一个中介者它知道每个租客的身份信息当有房屋出租后它会发送给每一个租客消息。   这样租客们中有一个变化活动时都会利用房屋中介发送消息到其他的租客。下面就是模仿的一个过程。   房屋中介代码如下 1 interface StateMediator{2 public void sell(Tenant tenant);3 }4 class RealEstateAgents implements StateMediator{5 private TenantA teA;6 private TenantB teB;7 private TenantC teC;8 9 public void sell(Tenant tenant) { 10 System.out.println(海景洋房 已经租出去了); 11 if(tenant instanceof TenantA){ 12 teB.crying(); 13 teC.crying(); 14 }else if(tenant instanceof TenantB){ 15 teA.crying(); 16 teC.crying(); 17 }else if(tenant instanceof TenantC){ 18 teB.crying(); 19 teA.crying(); 20 } 21 } 22 23 public void createAgents(){ 24 teA new TenantA(this); 25 teB new TenantB(this); 26 teC new TenantC(this); 27 } 28 }   租客的代码如下 1 abstract class Tenant{2 private RealEstateAgents agent;3 public Tenant(RealEstateAgents agent) {4 this.agent agent;5 }6 public abstract void crying();7 public void renting(){8 agent.sell(this);9 } 10 } 11 class TenantA extends Tenant{ 12 public TenantA(RealEstateAgents agent) { 13 super(agent); 14 } 15 public void crying() { 16 System.out.println(我是高富帅 TenantA哎呀我想要); 17 } 18 } 19 class TenantB extends Tenant{ 20 public TenantB(RealEstateAgents agent) { 21 super(agent); 22 } 23 public void crying() { 24 System.out.println(我是白富美 TenantB哎呀我想要); 25 } 26 } 27 class TenantC extends Tenant{ 28 public TenantC(RealEstateAgents agent) { 29 super(agent); 30 } 31 public void crying() { 32 System.out.println(我是穷屌丝 TenantC哎呀我想要); 33 } 34 }   产生的业务活动如下 1 public class ClientTest {2 public static void main(String[] args) {3 RealEstateAgents agent new RealEstateAgents();4 agent.createAgents();5 6 System.out.println(TeA 抢到了房子了);7 agent.sell(new TenantA(agent));8 9 System.out.println(过了两个月 TeB 抢到了房子了); 10 agent.sell(new TenantB(agent)); 11 } 12 }   运行结果 TeA 抢到了房子了 海景洋房 已经租出去了 我是白富美 TenantB哎呀我想要 我是穷屌丝 TenantC哎呀我想要 过了两个月 TeB 抢到了房子了 海景洋房 已经租出去了 我是高富帅 TenantA哎呀我想要 我是穷屌丝 TenantC哎呀我想要
http://www.pierceye.com/news/360274/

相关文章:

  • 网站建设推广专员岗位职责济南做企业网站公司
  • 网站不备案能解析吗合肥网站推广 公司哪家好
  • 网站描述怎样写深圳网站制作招聘
  • 二手车网站建设代理网页 国外
  • 广州制作网站静态网站首页更新
  • 个人网站用什么服务器宁波网站建设制作哪家好
  • 视频模板网站企业所得税优惠政策2022年
  • 坪山附近公司做网站建设哪家效益快wordpress 置顶 插件
  • 品牌网站建设服务机构内容网站管理系统
  • 电商网站建设基础ppt个人简单网站页
  • 移动端网站模板专业建站工作室
  • 企业网站建设的重要性及意义建设银行忘记密码网站首页
  • 易雅达网站建设公司广告设计公司设计收费标准
  • 行业门户网站php网站开发程序
  • 广州微信网站建设报价表上海注销营业执照流程
  • 陕西省建设执业资格注册中心网站科技有限公司 翻译
  • 做推广都有哪些网站网站怎么上传源码
  • discuz门户网站模板手机电子商务网站规划书范文
  • vps能同时做网站同时做其它事吗wordpress 支持小工具
  • 网站建设制作网络公司wordpress 汽车模板
  • 有哪些做外贸的网站网站快速搭建平台
  • wordpress搜索代码制做优化精灵
  • 连云港做网站推广东莞seo
  • 专业网站设计公司和普通设计公司的区别微信分销网站建设
  • 青海个人旅游网站建设网站建设教程软件下载
  • 做AMC12的题的网站龙华网站建设专业公司
  • 莱州网站制作友情链接交换形式
  • 如何编写网站做美食类网站现状
  • 一站式推广平台做家装模型的效果图网站
  • 企业电子商务网站开发实验报告苏州建筑设计公司排名