第六章结构型模式3.pptVIP

  • 5
  • 0
  • 约4.19千字
  • 约 21页
  • 2016-08-16 发布于河南
  • 举报
第六章结构型模式3

* * 6.3 Composite 组合模式 6.3.1 意图 将对象组合成树行结构表示 ”部分—整体” 的层次结构。Composite 使得用户对单个对象和组合对象的使用具有一致性。 叶结点 LeafNode NonLeafNode 对象 aPicture aPicture aLine aText aLine aRectangle aRectangle 典型的由递归组合的Graphic对象组成的组合对象结构 …… …… 6.3.2 适用性 以下情况使用Composite模式: 1. 你想表示的对象的部分—整体层次结构。 2. 你希望用户忽略组合对象与单个对象的不同,用户将统一地使用组合结构中 的所有对象。 Component NonLeafNode 1..n 非叶结点有1个或 多个节点 包含的每个对象 都是Component 对象 6.3.3 结构图 Component operation() add(Component) remove(Component) getChild(int) Client Composite operation() add(Component) remove(Component) getChild(int) Leaf

文档评论(0)

1亿VIP精品文档

相关文档