Search code examples
classumlclass-diagram

Either/OR class diagram


I'm working with exams in UML, and hope someone will be able to answer my question.

In the problem domain it says that every customer attending the event will have a contract, both inviduals and organizers. I ended up with a class diagram where I made associations between both inviduals and organizers to the contract class, please look at the attachment.

My question: Am I allowed to say that EITHER a invidual sign a contract OR an organizer sign a contract, by making associations to both?

enter image description here


Solution

  • To do so the best is maybe to introduce the "Customer" concept as depicted below. The association between Customer and Contract means that one Customer signs one Contrat and a Contract is Signed by one Customer. The inheritance links between Customer and both Organizer and Individual means that they are Customer which is allowed to sign a Contract.

    enter image description here

    If you want to keep your orginal design, you can add a constraint to express the fact that either an Individual or an Organizer can sign a Contract but it seems les elegant for me.

    enter image description here