设计模式之组合模式  Composite

设计模式之组合模式  Composite

设计模式之组合模式  Composite

 

 代码实现

//Component(抽象构件):抽象构件中定义了叶子和容器构件的共同点。比如,有公共的添加删除叶子功能,有显示节点功能。
public abstract class Component {
    protected String name;
    public Component(String name) {
        super();
        this.name = name;
    }
    public abstract void add(Component c);
    public abstract void remove(Component c);
    public abstract void display(int depth);
}
抽象组件

相关文章:

  • 2021-05-29
  • 2022-12-23
  • 2021-11-18
  • 2021-05-28
  • 2021-08-13
  • 2021-06-09
  • 2021-05-20
猜你喜欢
  • 2021-12-18
  • 2022-01-19
  • 2021-07-20
  • 2021-06-10
相关资源
相似解决方案