George
George

Reputation: 113

How do show conditional association in UML class diagram

I am using a UML class diagram to describe a gauge I've been asked to build for my employer. I am a mechE, and new to UML, but I am trying to develop disciplined habits. So far, this is what I have: gauge class diagram

My question concerns the Hardware class. I intend to show that a hardware class is can be comprised of only parts, only assemblies, or both parts and assemblies. My issue is that, as I look at this diagram, I think there exists a case where the hardware class can be comprised of no parts or assemblies.

Am I correct in this interpretation? Is there a way to describe an "or" condition to the classes comprising the hardware class? Or would I use a different diagram to describe this relationship?

Upvotes: 2

Views: 2822

Answers (1)

qwerty_so
qwerty_so

Reputation: 36313

You can simply overcome that by adding constraints to the connectors which tell that at least one must be non-zero.

enter image description here

Btw: look into the SysML profile. This is build especially for purposes like your case.

Upvotes: 1

Related Questions