Task Person - name : String 1 - leader - participant * * - take. Part. In Meeting - meeting. Name : String + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * a) Write an OCL constraint that states that: The number of participants (see role participant in figure) to a meeting must be at least 2. b) Write an OCL constraint that states that: The person given as leader of a meeting cannot also be participant to that same meeting.
In Magic. Draw
Make Package For the Constraints & Stereotype it to Validation. Suite
Make Constraint In the Validation. Suite Select this and than language, etc.
Select Constrained Element
The Constraint Must be Stereotyped to Validation. Rule
Set Error Message
Select in Menu: Analyze/Validation/Validate Select validation suite and validation selection
Person - participant * - name : String 1 - leader * - take. Part. In Meeting - meeting. Name : String + add. Participant(p : Person) : void + get. Leader() : Person - meeting. To. Lead * a) Write an OCL constraint that states that: The number of participants (see role participant in figure) to a meeting must be at least 2. context Meeting inv: participant->size() > = 2 b) Write an OCL constraint that states that: The person given as leader of a meeting cannot also be participant to that same meeting. context Meeting inv: participant->excludes(leader)
Generating Java Code Then Edit the Set Then Generate Code