链接: 软件设计模式与体系结构实验——2.1-1(2)(抽象)工厂模式的应用
链接: 软件设计模式与体系结构实验——2.2-1生成器模式的应用
链接: 软件设计模式与体系结构实验——2.3-1单列模式的应用

3.1-1组合模式的应用

  • 1. 实验目的
  • 2. 实验内容
  • 3. 模式UML图
  • 4. 模式添加代码(JAVA语言实现)
  • 5. 整体代码
    • (1)AirforceGUI及A类
    • (2)B1B、B2A、B52、Bomber
    • (3)C130E、C130J、CV22
    • (4)E9A、EC130、EPlane
    • (5)F15、F16、F22、Fighter
    • (6)Group、Squadron、Transporter
  • 6. 运行结果
  • 7. 实验小结

1. 实验目的

  1. 掌握组合模式的特点
  2. 分析具体问题,使用模式进行设计。

2. 实验内容

【作业3.1-1】在例3.3的设计中,添加一个空军大队( Wing)类,该类与Squadron、Group类是平行的,因此应该继承了AirUnit类。该类的写法与Squadron或者Group类是类似的,所不同的是一个Wing有216中类型的飞机。具体要求以及代码实现参见光盘的相应作业部分。

3. 模式UML图



本题目设计程序的设计类图,及其他图:

4. 模式添加代码(JAVA语言实现)

(1)Wing类

package com.glut.xusheng;/*=======================*/
/* Represents an air Wing      */
/*=======================*/public class Wing extends AirUnit{public static final String FEATURES = "A Wing with 216 aircrafts";Airforce[] fighters = new Airforce[162];Airforce[] bombers = new Airforce[18];Airforce[] transporters= new Airforce[18];Airforce[] eAircrafts = new Airforce[18];public Wing(){for(int k=0;k<162;k++){// need 162 fighters}for(int k=0;k<18;k++){// need 18 bombers}for(int k=0;k<18;k++){// need 18 transporters}for(int k=0;k<18;k++){// need 18 eAirplanes}}public String getDescription(){return FEATURES;}public String fight(){return super.fight();}
}

(2)GUI类:

private String[] AirForceUnit = {"SQUADRON", "GROUP", "WING"};
add(1, 6, airCheckBox[13]);
else if ((m==13) && (ckBoxStates[13] == SELECTED)){unit = new Wing();airUnits.attach(unit);unitInfo = unit.getDescription();
}

5. 整体代码

(1)AirforceGUI及A类

AirforceGUI类

package com.glut.xusheng;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Iterator;/*===================================================================*/
/* User interface for Testing the Composite design pattern program   */
/*===================================================================*/
public class AirforceGUI extends JFrame implements ItemListener{private JScrollPane checkBoxPane, textPane;private JSplitPane  splitPane;private JTextArea   txtAirMission;private JButton submitBtn, exitBtn;private JPanel checkBoxPanel, btnPanel, choicePanel;private JCheckBox[] airCheckBox;private JCheckBox[] airUnitCheckBox;private String[] airPlaneName ={"F-15E-Strike-Eagle","F-16C/D-Fighting-Falcon","F22A-Rapter","B-1B-Lancer","B-2A-Spirit","B-52H-Stratofortress","C-130E/H-Hercules","C-130J-Super-Hercules","CV-22B-Osprey","E-9A",  "EC-130H/J-Compass", "AirForce","Fighters","Bombers", "Transporters", "E-Planes"};//jiaprivate String[] AirForceUnit = {"SQUADRON", "GROUP", "WING"};public final int SELECTED = ItemEvent.SELECTED;public final int DESELECTED = ItemEvent.DESELECTED;private static final String[] OPTION = {"Solo", "Group"};private JComboBox[] optComoBox=new JComboBox[11];private int[] ckBoxStates;private GridBagLayout gridbag = new GridBagLayout();private GridBagConstraints gbc = new GridBagConstraints();public AirforceGUI(){super("Composite Pattern - Airforce");ckBoxStates = new int[50];setUpChoicePanel();setUpScrollPanes();}private void setUpChoicePanel(){submitBtn = new JButton("Submit");exitBtn = new JButton("Exit");submitBtn.addActionListener( new ButtonActionListener());exitBtn.addActionListener( new ButtonActionListener());JPanel btnPanel =new JPanel();btnPanel.add(submitBtn);btnPanel.add(exitBtn);int numCheckBox = airPlaneName.length;airCheckBox = new JCheckBox[numCheckBox];airUnitCheckBox = new JCheckBox[3];//Check boxes for selection of the airplanesfor(int m=0; m<numCheckBox; m++){airCheckBox[m]= new JCheckBox(airPlaneName[m]);airCheckBox[m].setMnemonic(KeyEvent.VK_C);airCheckBox[m].addItemListener(this);}//Check boxes for selection of air unitsfor(int m=0; m<3; m++){airUnitCheckBox[m]= new JCheckBox(AirForceUnit[m]);airUnitCheckBox[m].setMnemonic(KeyEvent.VK_C);airUnitCheckBox[m].addItemListener(this);}//Combobox for deciding on solo flight or notfor(int i=0;i<11;i++){optComoBox[i]= new JComboBox(OPTION);optComoBox[i].addItemListener(this);}checkBoxPanel = new JPanel();checkBoxPanel.setLayout(gridbag);for(int m=0; m<numCheckBox; m++)checkBoxPanel.add(airCheckBox[m]);for(int m=0; m<3; m++)checkBoxPanel.add(airUnitCheckBox[m]);for(int i=0;i<11;i++)checkBoxPanel.add(optComoBox[i]);gbc.insets.top = 0;gbc.insets.bottom = 0;gbc.insets.left = 0;gbc.insets.right = 0;gbc.anchor = GridBagConstraints.WEST;add(0, 0, airCheckBox[11]);add(1, 1, airCheckBox[12]);add(2, 3, airCheckBox[0]);add(2, 4, airCheckBox[1]);add(2, 5, airCheckBox[2]);//add(1, 6, airCheckBox[13]);add(2, 7, airCheckBox[3]);add(2, 8, airCheckBox[4]);add(2, 9, airCheckBox[5]);add(1, 10, airCheckBox[14]);add(2, 11, airCheckBox[6]);add(2, 12, airCheckBox[7]);add(2, 13, airCheckBox[8]);add(1, 14, airCheckBox[15]);add(2, 15, airCheckBox[9]);add(2, 16, airCheckBox[10]);add(3, 3, optComoBox[0]);add(3, 4, optComoBox[1]);add(3, 5, optComoBox[2]);add(3, 7, optComoBox[3]);add(3, 8, optComoBox[4]);add(3, 9, optComoBox[5]);add(3, 11, optComoBox[6]);add(3, 12, optComoBox[7]);add(3, 13, optComoBox[8]);add(3, 15, optComoBox[9]);add(3, 16, optComoBox[10]);add(0, 17, airUnitCheckBox[0]);add(0, 18, airUnitCheckBox[1]);add(0, 19, airUnitCheckBox[2]);choicePanel = new JPanel();choicePanel.setMinimumSize(new Dimension(500, 300));choicePanel.setLayout(new BorderLayout());choicePanel.add(checkBoxPanel, "Center");choicePanel.add(btnPanel, "South");}private void add(int m, int n, JComponent com ){gbc.gridx = m;gbc.gridy = n;gridbag.setConstraints(com, gbc);}private void setUpScrollPanes(){txtAirMission = new JTextArea(3,10);txtAirMission.setBackground(Color.cyan);txtAirMission.setText("选择军事单位:空军中队(SQUADRON),空军团(GROUP)或者空军大队(WING)"+ "\n组成固定单位的战斗力量。你也可以直接选择各种机型形成临时的编队"+"\n飞行(在组合框中选Group)或者单飞(在组合框中选Solo)。");checkBoxPane = new JScrollPane(choicePanel);textPane = new JScrollPane(txtAirMission);textPane.setMinimumSize(new Dimension(500, 100));splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, checkBoxPane, textPane);splitPane.setDividerLocation(470);getContentPane().add(splitPane);setSize(new Dimension(500, 500));setVisible(true);}//========================================// 新增加功能,需要理解本监听器所涉及的方法。//========================================class ButtonActionListener implements ActionListener{public void actionPerformed(ActionEvent e) {txtAirMission.setText("\n===Airforce New Mission===\n");createAirGroup(e);}}public void itemStateChanged(ItemEvent e){Object source = e.getItemSelectable();int state = e.getStateChange();if (source == airCheckBox[11]) {if(state == SELECTED){for(int m=12; m<16; m++)airCheckBox[m].setSelected(true);}else if (state == DESELECTED){for(int m=12; m<16; m++)airCheckBox[m].setSelected(false);}}else if (source ==  airCheckBox[12]) {if(state == SELECTED){for(int m=0; m<3; m++)airCheckBox[m].setSelected(true);}else if (state == DESELECTED){for(int m=0; m<3; m++)airCheckBox[m].setSelected(false);}}else if (source == airCheckBox[0])ckBoxStates[0]=state;else if (source == airCheckBox[1])ckBoxStates[1]=state;else if (source == airCheckBox[2])ckBoxStates[2]=state;else if (source == airCheckBox[13]){if(state == SELECTED){for(int m=3; m<6; m++)airCheckBox[m].setSelected(true);}else if (state == DESELECTED){for(int m=3; m<6; m++)airCheckBox[m].setSelected(false);}}else if (source == airCheckBox[3])ckBoxStates[3]=state;else if (source == airCheckBox[4])ckBoxStates[4]=state;else if (source == airCheckBox[5])ckBoxStates[5]=state;else if (source == airCheckBox[14]){if(state == SELECTED){for(int m=6; m<9; m++)airCheckBox[m].setSelected(true);}else if (state == DESELECTED){for(int m=6; m<9; m++)airCheckBox[m].setSelected(false);}}else if (source == airCheckBox[6])ckBoxStates[6]=state;else if (source == airCheckBox[7])ckBoxStates[7] = state;else if (source == airCheckBox[8])ckBoxStates[8]=state;else if (source == airCheckBox[15]){if(state == SELECTED){airCheckBox[9].setSelected(true);airCheckBox[10].setSelected(true);}else if (state == DESELECTED){airCheckBox[9].setSelected(false);airCheckBox[10].setSelected(false);}}else if (source == airCheckBox[9])ckBoxStates[9]=state;else if (source == airCheckBox[10])ckBoxStates[10]=state;//== for air unitselse if (source == airUnitCheckBox[0])ckBoxStates[11]=state;else if (source == airUnitCheckBox[1])ckBoxStates[12]=state;else if (source == airUnitCheckBox[2])ckBoxStates[13]=state;}private void createAirGroup(ActionEvent e){Airforce airCraft = null;Airforce unit = null;AirUnit airGroup = new AirUnit();AirUnit airUnits = new AirUnit();boolean isSolo = false;int len = ckBoxStates.length;String unitInfo = null;if (e.getActionCommand().equals("Submit")) {for(int m = 0; m < len; m++ ){if ((m==0) && (ckBoxStates[0] == SELECTED)) {airCraft = new F15();if(optComoBox[0].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==1) && (ckBoxStates[1] == SELECTED)){airCraft = new F16();if(optComoBox[1].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==2) && (ckBoxStates[2] == SELECTED)){airCraft = new F22();if(optComoBox[2].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==3) && (ckBoxStates[3] == SELECTED)){airCraft = new B1B();if(optComoBox[3].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==4) && (ckBoxStates[4] == SELECTED)) {airCraft = new B2A();if(optComoBox[4].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==5) && (ckBoxStates[5] == SELECTED)){airCraft = new B52();if(optComoBox[5].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==6) && (ckBoxStates[6] == SELECTED)) {airCraft = new C130E();if(optComoBox[6].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==7) && (ckBoxStates[7] == SELECTED)) {airCraft = new C130J();if(optComoBox[7].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==8) && (ckBoxStates[8] == SELECTED)) {airCraft = new CV22();if(optComoBox[8].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==9) && (ckBoxStates[9] == SELECTED)) {airCraft = new E9A();if(optComoBox[9].getSelectedItem().equals("Solo"))isSolo = true;}else if ((m==10) && (ckBoxStates[10] == SELECTED)) {airCraft = new EC130();if(optComoBox[10].getSelectedItem().equals("Solo"))isSolo = true;}//== for air unitselse if ((m==11) && (ckBoxStates[11] == SELECTED)){unit = new Squadron();airUnits.attach(unit);unitInfo = unit.getDescription();}else if ((m==12) && (ckBoxStates[12] == SELECTED)){unit = new Group();airUnits.attach(unit);unitInfo = unit.getDescription();}else if ((m==13) && (ckBoxStates[13] == SELECTED)){unit = new Wing();airUnits.attach(unit);unitInfo = unit.getDescription();}if( airCraft != null){if(isSolo == false)airGroup.attach(airCraft);else{String f = airCraft.fight();txtAirMission.append("Solo Flight Mission: \n" + f + "\n");}airCraft = null;isSolo = false;}}  //end for loop//Display Air Group Actionsif(airGroup.getSize() > 0){String str = airGroup.fight();txtAirMission.append("Mission with newly-formed unit: \n" + str + "\n");}if(airUnits.getSize() > 0){String str = airUnits.fight();txtAirMission.append("Mission with fixed unit: \n" + unitInfo + " \n");txtAirMission.append("Aircrafts in this mission: \n" + str + "\n");}}else if (e.getActionCommand().equals("Exit")) {System.exit(1);}}public static void main(String args[]){try {JFrame.setDefaultLookAndFeelDecorated(true);//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");}catch (Exception evt) {}AirforceGUI frame = new AirforceGUI();frame.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});frame.setSize(500, 600);frame.setVisible(true);}
}

Airforce类

package com.glut.xusheng;/*===================================*/
/* This is the interface of a class  */
/* hierarchy that is to be visited   */
/* by some visitors                  */
/*===================================*/public abstract interface Airforce {public abstract String fight();public abstract String getDescription();
}

AirUnit类

package com.glut.xusheng;import java.util.ArrayList;
import java.util.Iterator;/*=====================================*/
/* This is the object structure  class */
/* in the class diagram of the visitor */
/* design pattern                      */
/*=====================================*/public class AirUnit implements Airforce{private ArrayList<Airforce> parts;private String answer="";private String FEATURES = "Air Formation of Airforce. ";public AirUnit(){parts = new ArrayList<Airforce>();}public void attach(Airforce equip){if(equip != null)parts.add(equip);}public void detach(Airforce equip){if(equip != null)parts.remove(equip);}public Iterator<Airforce>  elements(){return parts.iterator();}public String fight(){int len =parts.size();for (int i=0; i < len; i++){Airforce part = parts.get(i);answer = answer + part.fight()+"\n";}return answer;}public int getSize(){return parts.size();}public String getDescription(){return FEATURES;}
}

(2)B1B、B2A、B52、Bomber

B1B类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class B1B extends Bomber{public static final String FEATURES = "B1B Lancer";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

B2A类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class B2A extends Bomber{public static final String FEATURES = "B2A Spirit";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

B52类

package com.glut.xusheng;public class B52 extends Bomber{public static final String FEATURES = "B52H StratoFortress";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

Bomber类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public abstract class Bomber implements Airforce{public static final String FEATURES = "Bombers ";public String getDescription(){return FEATURES;}public abstract String fight();}

(3)C130E、C130J、CV22

C130E类

package com.glut.xusheng;public class C130E extends Transporter{public static final String FEATURES = "C130EH Hercules";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

C130J类

package com.glut.xusheng;public class C130J extends Transporter{public static final String FEATURES = "C130J Super Hercules";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

CV22类

package com.glut.xusheng;public class CV22 extends Transporter{public static final String FEATURES = "CV22BO Sprey";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

(4)E9A、EC130、EPlane

E9A类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class E9A extends EPlane{public static final String FEATURES = "E9A ";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

EC130类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class EC130 extends EPlane{public static final String FEATURES = "EC130HJ Compass";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

EPlane类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public abstract class EPlane implements Airforce{public static final String FEATURES = "EPlanes ";public String getDescription(){return FEATURES;}public abstract String fight();}

(5)F15、F16、F22、Fighter

F15类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class F15 extends Fighter{public static final String FEATURES = "F15E Strike Eagle";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

F16类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class F16 extends Fighter{public static final String FEATURES = "F16CD Fighting Falcon";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

F22类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public class F22 extends Fighter{public static final String FEATURES = "F22A Rapter";public String getDescription(){return FEATURES;}public String fight(){return FEATURES + " Ready to fight!";}}

Fighter类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public abstract class Fighter implements Airforce{public static final String FEATURES = "Fighter Airplanes";public String getDescription(){return FEATURES;}public abstract String fight();}

(6)Group、Squadron、Transporter

Group类

package com.glut.xusheng;/*=======================*/
/* Represents an air Group    */
/*=======================*/public class Group extends AirUnit{public static final String FEATURES = "A Group with 72 aircrafts";Airforce[] fighters = new Airforce[54];Airforce[] bombers = new Airforce[6];Airforce[] transporters= new Airforce[6];Airforce[] eAircrafts = new Airforce[6];public Group(){for(int k=0;k<54;k++){fighters[k] = new F22();super.attach(fighters[k]);}for(int k=0;k<6;k++){bombers[k] = new B52();super.attach(bombers[k] );}for(int k=0;k<6;k++){transporters[k] = new C130J();super.attach(transporters[k]);}for(int k=0;k<6;k++){eAircrafts[k] = new E9A();super.attach(eAircrafts[k]);}}public String getDescription(){return FEATURES;}public String fight(){return super.fight();}
}

Squadron类

package com.glut.xusheng;
/*==========================*/
/* Represents an air Squadron    */
/*==========================*/public class Squadron extends AirUnit{public static final String FEATURES = "A Quadron with 24 aircrafts";Airforce[] fighters = new Airforce[18];Airforce[] bombers = new Airforce[2];Airforce[] transporters= new Airforce[2];Airforce[] eAircrafts = new Airforce[2];public Squadron(){for(int k=0;k<18;k++){fighters[k] = new F22();super.attach(fighters[k]);}for(int k=0;k<2;k++){bombers[k] = new B52();super.attach(bombers[k] );}for(int k=0;k<2;k++){transporters[k] = new C130J();super.attach(transporters[k]);}for(int k=0;k<2;k++){eAircrafts[k] = new E9A();super.attach(eAircrafts[k]);}}public String getDescription(){return FEATURES;}public String fight(){return super.fight();}
}

Transporter类

package com.glut.xusheng;/*================================*/
/* Represents a kind of airforce  */
/*================================*/public abstract class Transporter implements Airforce{public static final String FEATURES = "Transporters ";public String getDescription(){return FEATURES;}public abstract String fight();
}

6. 运行结果


7. 实验小结

(1)组合(Composite Pattern)模式的定义:
有时又叫作整体-部分(Part-Whole)模式,它是一种将对象组合成树状的层次结构的模式,用来表示“整体-部分”的关系,使用户对单个对象和组合对象具有一致的访问性,属于结构型设计模式。
组合模式一般用来描述整体与部分的关系,它将对象组织到树形结构中,顶层的节点被称为根节点,根节点下面可以包含树枝节点和叶子节点,树枝节点下面又可以包含树枝节点和叶子节点,树形结构图如下。
组合模式共分为三种角色:

1.Component(抽象构件):叶子构件与容器构件共同继承的父类或者是共同实现的接口,该角色中包含所有子类共有方法的声明和实现,在抽象构件中定义了管理子构件的方法,新增构件、删除构件、获取构件。
2.Leaf(叶子构件):表示叶子节点,没有子节点,对于继承父类的管理子节点的方法以抛出异常的方式处理。
3.Composite(容器构件):表示容器节点,包含子节点,子节点可以是容器节点也可以是叶子节点,其提供一个集合来对子节点进行维护,以迭代的方式对子节点进行处理。
组合模式的关键是抽象构件类,它既可以表示叶子节点也可以表示容器节点,对于客户端而言是统一对抽象构件进行处理的,抽象构件类和容器构件类是聚合关联的关系,抽象构件类是容器构件类的一部分,这样容器构件类对子构件进行处理时不用区分是叶子节点还是容器节点,能够统一的做处理。

(2)组合模式的注意事项和细节:

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

软件设计模式与体系结构实验——3.1-1组合模式的应用相关推荐

  1. 软件设计模式与体系结构实验——2.1-1(2)(抽象)工厂模式的应用

    文章目录 一.实验三 工厂模式的应用 1.实验目的 2.实验内容 3.模式UML图 4.模式代码 5.运行截图 6.实验小结 二.实验四 抽象工厂模式的应用 1.实验目的 2.实验内容 3.模式UML ...

  2. 软件设计模式与体系结构实验汇总

    实验一 工厂模式的应用 有一个OEM制造商代理做HP笔记本电脑(Laptop),后来该制造商得到了更多的品牌笔记本电脑的订单Acer,Lenovo,Dell,该OEM商发现,如果一次同时做很多个牌子的 ...

  3. 软件设计模式与体系结构 课后练习1

    软件设计模式与体系结构 课后练习1 习题如下: 解:第一题 画出该模式的设计类图: 如图1所示: 图1 设计类图 2.  解释为什么自己的设计符合开闭原则? 答:因为设计的类.模块和函数对扩展开放,对 ...

  4. 软件设计模式与体系结构(上)

    目录 软件设计模式概述(面向对象设计概述) 一.面向对象设计的表示方法 1. UML 二.面向对象的设计原则 1.单一原则 2.开闭原则 3.里氏代换原则 4.依赖倒转原则 5.接口隔离原则 6.合成 ...

  5. 23种设计模式C++源码与UML实现--组合模式

    组合模式 Composite模式也叫做组合模式,是构造型的设计模式之一.通过递归的手段构造树形的对象结构,并可以通过一个对象来访问整个对象树. Component树形结构的节点抽象 为所有的对象定义统 ...

  6. 设计模式学习笔记(九)——Composite组合模式

    Composite组合模式主要是应对这样的问题:一类具有"容器特征"的对象--即他们在充当对象的同时,又是其他对象的容器的情况.在编写时我们常常会造成:客户代码过多地依赖于对象容器 ...

  7. 软件设计模式与体系结构(中)

    目录 软件体系结构概述 一.软件体系结构的定义 二.软件体系结构的优势 经典软件体系结构 一.调用-返回风格软件体系结构 1.主程序-子程序 2.面向对象 二.数据流风格软件体系结构 1.顺序批处理软 ...

  8. 软件设计与体系结构实验报告

    1.实验名称 面向对象程序设计-类模型的设计 2.实验目的 通过实验,熟悉并掌握面向对象程序设计模式的选取.设计过程. 3.实验内容 设计和实现中通快修APP系统的模式设计,完成类模型图. 实验过程 ...

  9. 软件设计模式及体系结构之工厂方法模式

    前言 创建模式 创建型模式( Creational pattern)对类的实例化过程进行了抽象,能够将软件模块中对象的创建和对象的使用分离. 为了使软件的结构更加清晰,外界对于这些对象只需要知道它们共 ...

最新文章

  1. Oracle数据库中的分页--rownum
  2. 常微分方程数值解:欧拉公式
  3. NLP技术中的Tokenization
  4. linux下安装python(安装python 3.6稳定版成功亲测)
  5. C 学习笔记 - 数组
  6. 优秀logo设计解析_优秀Logo设计!字母造型解析
  7. 基于云的平台利用新技术来改变商店式购物营销
  8. php设置http请求头信息和响应头信息
  9. UVA10018 Reverse and Add【回文数+水题】
  10. Git(5)-- 获取 Git 仓库(git init 和 git clone命令)
  11. javaw java_java与javaw区别
  12. delphi 安装控件时提示系统找不到指定的模块的解决
  13. 计算机efs加密,win7系统对文件启用EFs加密功能的处理办法
  14. 测试POST传输工具【poster】。
  15. ROS | launch启动文件的使用
  16. linux dd 填充全ff,用shell命令tr dd生成内容为FF指定大小的命令。
  17. 程序员述职报告和转正
  18. 人脸识别(cv2库的实现)
  19. 把图片压缩成指定大小,释放你的内存空间
  20. Pycharm的快捷键

热门文章

  1. K8s系列之:搭建高可用K8s v1.23.5集群详细步骤,3个master节点,3个Node节点
  2. 托科技的福,学不好外语就别学了!| 技术前沿洞察
  3. 麻烦不断!盘点苹果过去的一年惹上的“幺蛾子”
  4. 红米k30 允许调用gpu调试层_记一次APP的so层算法逆向(六)
  5. adnroid 系统OTA升级
  6. 警惕黑客使用Lion系统漏洞破解和修改用户登陆密码
  7. 详解转换说明%-3d、%3d、%nd、%*2d、%0nd、%0.1f、%5.1f、%*d等含义
  8. html中上下左右控制对象移动Demo
  9. 单招问你为什么学计算机,单招面试难吗 单招面试一般会问什么问题
  10. android沉浸式的实现