Purpose and task Objective: familiar with the UML, familiar with the adapter, combined mode. Task: following the experimental content requires the complete adapter, the combination function mode implementation of experiment. |
|||||||||
Content preview UML review the contents of the course, familiar with the use of an adapter, combination mode. |
|||||||||
Experiment contents and requirements
1, the conventional method of a class Square SQU (a float L) for calculating the area of a square, are now required for calculating the Circle class inscribed circle of a square area, implement the output area of the adapter mode, the multiplexing claim Square , draw the class diagram and coding.
There are the following scene: structure of the university is: University - College - Department, please according to our school instantiate the structure and requirements of college can send a message to the specified line (for example: School of Computer Science and Engineering can send a message to software engineering based), please draw mode with a combination of class and coding FIG. |
|||||||||
The results (available Continued) A: Adapter mode :
Target (target abstract class): Circle.java:
Adapter (adapter class): Adapter.java:
The Adaptee (adaptation by category): Square.java:
Main: Main.java: II: combined mode : Component(抽象构件): univComponent.java:
Leaf(叶子构件): Department.java:
Composite(容器构件): College,java:
Univ.java:
Main: Main.java:
思考题:
类适配器需要通过创建自身创建出一个新的Adapter,对象适配器可以通过已有的Adapter对象来装换接口类适配器通过覆写来扩展specificRequest(),对象适配器是包含关系不能扩展类适配器因为是继承所以相对静态,对象适配器是包含,所以相对灵活 2、算术运算:1+2中1、2是运算量,+是运算符,另外1+(2*3)也是算术运算,但是包含了(2*3),本身也是算术运算,请结合组合模式给出该算术运算的类图。
|
Adapter, combined mode
Guess you like
Origin blog.csdn.net/yszbrzdd/article/details/93521322
Recommended
Ranking