0

In a class diagram, is it possible to have two classes with more than one relationship? For example, a generalization relationship and a composition relationship?

For instance,

You can have either a composition relationship or a generalization relationship. A frozen Chocolate is a chocolate. But if you destroy the chocolate class the frozen chocolate class would also be destroyed. which also makes it a composition relationship.

But can you have both on the same diagram, or would you have to stick to one? Which one in this case?

Marcello
  • 423
  • 1
  • 5
  • 12

1 Answers1

1

This is a generalization relationship, FrozenChocolate is a Chocolate but adds extra properties. It is not a compositions, you cannot say that Chocolate has a FrozenChocolate.

Your argument about destroying Chocolate resulting in FrozenChocolate also being destroyed is invalid. These are not object instances. You cannot say that destroying Animal means that Dog is destroyed.

ColinE
  • 68,894
  • 15
  • 164
  • 232