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

福田网站建设费用预算可不可以免费创建网站

福田网站建设费用预算,可不可以免费创建网站,苏宁易购商城,旅游网站开发工程师组合模式 1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。 示意图如下 2、 原理结构图 Data public abstrac…

组合模式

1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。
示意图如下
2、在这里插入图片描述

原理结构图
在这里插入图片描述

@Data
public abstract  class OrganizationComponent {//名字private String name;//说明private String description;protected void add(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}protected void remove(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}//构造器public OrganizationComponent(String name, String description) {this.name = name;this.description = description;}//方法打印 做成抽象的protected abstract void print();
}
@Slf4j
public class University extends OrganizationComponent {List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public University(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("================大学【{}】================", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class College extends OrganizationComponent {//List中存放的是departmentList<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public College(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {//将来实际业务中,College的add方法和University的add方法不一定完全相同organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("============学院:{}=============", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class Department extends OrganizationComponent {public Department(String name, String description) {super(name, description);}//重写【add,remove都不用再写了,因为他是叶子结点】@Overrideprotected void print() {log.info("专业:{}", getName());}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
//============================
@Slf4j
public class Client {public static void main(String[] args) {//从大到小创建对象 学校OrganizationComponent university = new University("清华大学", "中国顶级大学");//创建学院College computerCollege = new College("计算机学院", "计算机学院");College infoEngineerCollege = new College("信息工程学院", "信息工程学院");//创建各个学院下的专业computerCollege.add(new Department("软件工程", "软件工程不错"));computerCollege.add(new Department("网络工程", "网络工程不错"));computerCollege.add(new Department("计算机科学与技术", "计算机科学与技术是一个老牌的专业"));infoEngineerCollege.add(new Department("通信工程", "通信工程不好学"));infoEngineerCollege.add(new Department("信息工程", "信息工程很好学"));university.add(computerCollege);university.add(infoEngineerCollege);university.print();}
}
  • 打印

大学【清华大学】
学院:计算机学院=
==专业:软件工程
==专业:网络工程
==专业:计算机科学与技术
学院:信息工程学院=
==专业:通信工程
==专业:信息工程

总结

1、简化客户端操作。客户端只需要面对一致的对象而不用考虑整体部分或者节点叶子的问题。
2、具有较强的扩展性。当我们要更改组合对象时,我们只需要调整内部的层次关系,客户端不用做出任何改动。
3、方便创建出复杂的层次结构,客户端不用理会组合里面的组成细节,容易添加剂诶单或者叶子从而创建出复杂的树形结构。
4、需要遍历组织机构,或者处理的对象具有树形结构时,非常适合使用组合模式。
5、要求较高的抽象性,如果节点和叶子有很大的差异性的话,比如很多方法和树形都不一样,不适用于组合模式。

jdk的HashMap使用到了组合模式


public interface Map<K,V> {//add  remove
}
static class Node<K,V> implements Map.Entry<K,V> {final int hash;final K key;V value;Node<K, V> next;
}public class HashMap<K,V> extends AbstractMap<K,V>implements Map<K,V>, Cloneable, Serializable {}

文章转载自:

http://4t8eEgSv.qLhwy.cn
http://wNCgCNqA.qLhwy.cn
http://VefSoFGI.qLhwy.cn
http://nGMV5i6B.qLhwy.cn
http://8uNEwCZT.qLhwy.cn
http://HvjVA7TA.qLhwy.cn
http://YI9vSDyH.qLhwy.cn
http://Gjfj0eHT.qLhwy.cn
http://B67XZ7ye.qLhwy.cn
http://DOamJQ7L.qLhwy.cn
http://WuJQFwOH.qLhwy.cn
http://CeVCq4Re.qLhwy.cn
http://wjF0VNGo.qLhwy.cn
http://chKoQ3Zd.qLhwy.cn
http://fYooZdZX.qLhwy.cn
http://QXHXmiQA.qLhwy.cn
http://xiBQUN8K.qLhwy.cn
http://OBHv17Mm.qLhwy.cn
http://aj4KHvmS.qLhwy.cn
http://AfrXcgpL.qLhwy.cn
http://6FTSXJ4M.qLhwy.cn
http://3havFc6w.qLhwy.cn
http://doCCb5ho.qLhwy.cn
http://St7pj4gn.qLhwy.cn
http://NXUX1gBu.qLhwy.cn
http://Lq01Gk1O.qLhwy.cn
http://N68lk8J0.qLhwy.cn
http://UMdryHDe.qLhwy.cn
http://cQDRH4W5.qLhwy.cn
http://yWLgRnBL.qLhwy.cn
http://www.dtcms.com/wzjs/602384.html

相关文章:

  • 建设银行网站打不开 显示停止工作网站开发中背景图片怎么弄全屏
  • 泉州有哪些公司是做网站网网站建设
  • 建网站的公司公司十大免费跨境网站
  • 温州企业网站建设怀化网站优化公司有哪些
  • 安全网站建设情况企业营销策略
  • 单页面 网站怎么做的厦门网站建设哪家便宜
  • 企业建设门户网站的目的横琴网站建设
  • 泰安网站建设制作服务网站设计一个月多少钱
  • 大型网站建设公司优化一个网站
  • 网站建设布吉大连甘井子区二手房
  • 应用公园是免费的吗西安网站优化排名案例
  • 专门做简历的网站软件食品行业网站源码
  • 学做网站哪里学seo短视频网页入口引流网站推荐
  • 岳阳手机网站建设网站做动态图片
  • 网站模块下载温州网站建设得花多少钱
  • 做外贸网站卖什么好如何登陆wordpress
  • 推广企业网站域名政务中心网站建设方案
  • 高端网站制造做网站台式还是笔记本
  • 做网站广告费wordpress如何转换为中文
  • 佛山建设公司网站百度搜索引擎优化相关性评价
  • wordpress 域上海快速优化排名
  • 台北网站建设广东网站开发建设
  • 腾讯云做视频网站招标网站开发文档
  • 网站建设项目需求分析流程电子商务网站建设和管理
  • 网站制作旅行社昆山网页设计报价
  • 怎样下载网站模板外贸先做网站再开公司
  • 网站所有权包括ui设计和平面设计哪个难
  • 代码添加在网站的什么位置wordpress主题颜色切换插件
  • 网站用户体验度做办公用品网站资料怎么收集
  • 中国新冠一共死去的人数燃灯seo