3.4 The relationship between Circle and Point
The following class diagram shows the relationship between the Circle class and the Point class.
- A Circle contains one Point;
- A Point can belong to one or more Circles;
- The Circle knows about the Point;
- The Point knows nothing about the Circle to which it belongs;
- This relationship is called unidirectional and is represented by an open arrow on the child side.
This is design 2: Circle stores a Point and the all-args constructor accepts that Point, so several circles can share it. Three ways to give a Circle a centre compares this association with design 1 (numbers on Circle) and with composition (design 3, where Circle always creates the Point itself).