Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you have to design an application for drawing 2D geometric shapes. Some

ID: 3924112 • Letter: S

Question

Suppose you have to design an application for drawing 2D geometric shapes.
Some shapes are complex and may contain one or more shapes, basic or complex. For instance, a House shape includes 3 Rectangle (basic) shapes, a Chimney shape, and an Ellipse (basic) shape. The Chimney is a complex shape and includes 4 Line shapes. A complex shape behaves like a basic shape but also allows one to add/remove basic shapes to/from it.

What design pattern must be applied to these shape concepts ?

Strategy

Observer

Decorator

Composite

I think the asnwer is composite, since this pattern groups components into a whole.

Strategy

Observer

Decorator

Composite

I think the asnwer is composite, since this pattern groups components into a whole.

Explanation / Answer

For the above design we can use Composite design pattern, the composite design is the structured design pattern so that your answer is correct and the composite is a tree structure of simple and composite objects.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote