Simple Note
From reference:
the composite pattern is a partitioning design pattern. The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.
Program
https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/composite
Run TestMain.java to test.
A Calculator probably consists of several child Calculators, you can change mode from parent Calculator then get result as needed.
References:
Composite pattern
No comments:
Post a Comment