Skip to content

3.4 The relationship between Circle and Point

The following class diagram shows the relationship between the Circle class and the Point class.

Circle and Point with many-to-one association: each Circle has one Centre Point Circle and Point with many-to-one association: each Circle has one Centre Point
  • 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).