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

免费做h5的网站公众号怎么制作投票活动

免费做h5的网站,公众号怎么制作投票活动,网站每年多少钱,企业建设网站的案例文章目录 一、组合模式定义二、例子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.yayakq.cn/news/360552/

相关文章:

  • 网站竞价托管安康公司网站制作
  • 上海网站制作衫阿玛尼手表
  • 《30天网站建设实录》景点网站建设方案
  • 知名网站定制公司电话网站建设 意向协议书
  • 百度有没有做游戏下载网站网页游戏排行榜2014前十名
  • 贵金属网站建设公司网站制作设计联系方式
  • 怎么用网站模板长沙外贸企业网站建设
  • 深圳图派做的网站后台加什么深圳市宝安区松岗街道
  • 外汇网站怎么做优外汇网站网站网络排名优化方法
  • 温州做网站技术员免费开源的建站系统
  • 呼和浩特做网站广告创意设计大赛
  • 杭州网站定制建设网站需要的软硬件
  • 只做网站不推广能行吗九冶建设有限公司官方网站
  • 扁平式网站天津网站优化公司哪家好
  • 百度极速版推广员怎么申请谷歌seo是指什么意思
  • wordpress 外卖泰州网站快速排名优化
  • 网站点击率如何做wordpress返回首页一直加载
  • 建公司网站的公司跨境电商怎么做流程
  • 介绍好的电影网站模板下载网站如何启用gzip压缩
  • 咖啡网站建设的需求分析wordpress 不能评论
  • 怎样设计一个公司网站百度关键词热度排名
  • 怎么解决360导航的网站建设做招聘信息的网站有哪些内容
  • 建设部网站城市规划资质标准陕西建设执业注册中心网站
  • 深圳建站公司告诉你十个建站步骤冷门却好听的公司名称
  • 怎么查网站到期时间崇州园区营销网站建设
  • 湛江做网站seo湖南广告优化
  • 网站建设swot市场分析临沂森工木业有限公司
  • 网站案例英文新浪网页游戏
  • 用动易做的诗歌协会网站推荐几个网站图片网站
  • 成都教育网站建设公司价格自适应网页模板制作教程