Login :
Password :

Design patterns

Adap black box class protocol

Problem wording :

Design a drawing editor. A design is composed of graphics (lines, rectangles and roses), positioned at precise positions. Each graphic form must be modeled by a class that provides a method draw(): void. A rose is a complex graphic designed by a "black-box" class component. This component performs this drawing in memory, and provides access through a method getRose(): int that returns the address of the drawing. It is probable that the system evolves in order to draw circles.

Optimal solution :

Static diagram :

Static diagram

In this solution, we use a delegation link to adapt the Rose class to the Shape class.

Les têtes de mule
Cédric BOUHOURS
Cédric BOUHOURS
Cédric BOUHOURS