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

网站建设确认单软文大全

网站建设确认单,软文大全,拥有域名后怎么搭建网站,生鲜b2c网站建设规划书文章目录 一、组合模式定义二、例子2.1 菜鸟教程例子2.1.1 创建 Employee 类,该类带有 Employee 对象的列表。2.1.2 使用 Employee 类来创建和打印员工的层次结构。 2.2 JDK源码——java.awt.Container2.3 Spring源码——CompositeCacheManager 三、其他设计模式 一…

文章目录

  • 一、组合模式定义
  • 二、例子
    • 2.1 菜鸟教程例子
      • 2.1.1 创建 Employee 类,该类带有 Employee 对象的列表。
      • 2.1.2 使用 Employee 类来创建和打印员工的层次结构。
    • 2.2 JDK源码——java.awt.Container
    • 2.3 Spring源码——CompositeCacheManager
  • 三、其他设计模式

一、组合模式定义

类型: 结构型模式
介绍: 一种树形结构。它又叫部分整体模式,是用于把一组相似的对象当作一个单一的对象。
目的: 组合模式依据树形结构来组合对象,用来表示部分以及整体层次。

二、例子

2.1 菜鸟教程例子

2.1.1 创建 Employee 类,该类带有 Employee 对象的列表。

public class Employee {private String name;private String dept;private int salary;private List<Employee> subordinates;//构造函数public Employee(String name,String dept, int sal) {this.name = name;this.dept = dept;this.salary = sal;subordinates = new ArrayList<Employee>();}public void add(Employee e) {subordinates.add(e);}public void remove(Employee e) {subordinates.remove(e);}public List<Employee> getSubordinates(){return subordinates;}public String toString(){return ("Employee :[ Name : "+ name +", dept : "+ dept + ", salary :"+ salary+" ]");}   
}

2.1.2 使用 Employee 类来创建和打印员工的层次结构。

public class CompositePatternDemo {public static void main(String[] args) {Employee CEO = new Employee("John","CEO", 30000);Employee headSales = new Employee("Robert","Head Sales", 20000);Employee headMarketing = new Employee("Michel","Head Marketing", 20000);Employee clerk1 = new Employee("Laura","Marketing", 10000);Employee clerk2 = new Employee("Bob","Marketing", 10000);Employee salesExecutive1 = new Employee("Richard","Sales", 10000);Employee salesExecutive2 = new Employee("Rob","Sales", 10000);CEO.add(headSales);CEO.add(headMarketing);headSales.add(salesExecutive1);headSales.add(salesExecutive2);headMarketing.add(clerk1);headMarketing.add(clerk2);//打印该组织的所有员工System.out.println(CEO); for (Employee headEmployee : CEO.getSubordinates()) {System.out.println(headEmployee);for (Employee employee : headEmployee.getSubordinates()) {System.out.println(employee);}}        }
}

2.2 JDK源码——java.awt.Container

public class Container extends Component {private java.util.List<Component> component = new ArrayList<>();public Component getComponent(int n) {try {return component.get(n);} catch (IndexOutOfBoundsException z) {throw new ArrayIndexOutOfBoundsException("No such child: " + n);}}public Component add(Component comp) {addImpl(comp, null, -1);return comp;}}

2.3 Spring源码——CompositeCacheManager

public class CompositeCacheManager implements CacheManager, InitializingBean {private final List<CacheManager> cacheManagers = new ArrayList();@Nullablepublic Cache getCache(String name) {Iterator var2 = this.cacheManagers.iterator();Cache cache;do {if (!var2.hasNext()) {return null;}CacheManager cacheManager = (CacheManager)var2.next();cache = cacheManager.getCache(name);} while(cache == null);return cache;}
}

三、其他设计模式

创建型模式
结构型模式

  • 1、设计模式——装饰器模式(Decorator Pattern)+ Spring相关源码

行为型模式

  • 1、设计模式——访问者模式(Visitor Pattern)+ Spring相关源码
  • 2、设计模式——中介者模式(Mediator Pattern)+ JDK相关源码
  • 3、设计模式——策略模式(Strategy Pattern)+ Spring相关源码
  • 4、设计模式——状态模式(State Pattern)
  • 5、设计模式——命令模式(Command Pattern)+ Spring相关源码
  • 6、设计模式——观察者模式(Observer Pattern)+ Spring相关源码
  • 7、设计模式——备忘录模式(Memento Pattern)
  • 8、设计模式——模板方法模式(Template Pattern)+ Spring相关源码
  • 9、设计模式——迭代器模式(Iterator Pattern)+ Spring相关源码
  • 10、设计模式——责任链模式(Chain of Responsibility Pattern)+ Spring相关源码
  • 11、设计模式——解释器模式(Interpreter Pattern)+ Spring相关源码
http://www.hkea.cn/news/178755/

相关文章:

  • 阿里云网站建设的实训报告免费的自媒体一键发布平台
  • 关于加强网站建设的意见企业获客方式
  • 帮企业建设网站保密合同优化设计电子课本
  • 金山石化网站建设广告电话
  • 网站开发 前景网络推广代理
  • 温州整站推广咨询seo网站推广专员
  • 企业营销型网站团队百度seo排名优化教程
  • 安徽平台网站建设哪里好网络策划与营销
  • 做网站接广告赚钱么凡科建站和华为云哪个好
  • 成都网站建设科技公seo营销外包公司
  • 重庆有哪些做网站 小程序的百度搜索引擎的特点
  • 仁怀哪里可以做网站自动秒收录网
  • 重庆市建设局网站推广软件一键发送
  • 合肥网络推广网络运营网站seo诊断分析和优化方案
  • 网站优化公司免费咨询sem优化推广
  • 个人做网站赚钱么宁波seo推荐推广平台
  • 员工支付做网站的费用分录成都营销型网站制作
  • 专业做网站的公司邢台专业做网站关键词搜索优化
  • 电商网站建设方案模板杭州百度首页优化
  • 网站建设服务价格东莞市网站建设
  • 网站开发所需要的的环境佛山网络推广哪里好
  • php网站的优点关键路径
  • 电子政务与网站建设 总结湖南网站推广
  • 境外网站做网站涉黄互联网媒体广告公司
  • 河南做网站公司汉狮怎么做蛋糕
  • 哈 做网站网店代运营收费
  • 制作网页的三大技术是什么郑州seo顾问
  • 网站建设报价流程行业网站网址
  • 提供邯郸做wap网站网页推广方案
  • 网站从域名广告营销公司