I have 2 classes: Box and Apple.
A Box contains Apples. An apple can only ever belong to one box. An apple must belong to a box. Each apple has a position in the box. This could be managed either by Apple or by Box. An apple also contains a bunch of other properties not relevant to Box. An apple can be moved from one box to another.
But how can I enforce the constraints above?
The only idea I have is that a box keeps track of the position of an apple and also have a static dictionary mapping an apple to a board, but this seems like not good design?
Aucun commentaire:
Enregistrer un commentaire