4

I'm trying to make a conceptual model of this use case:

The Actor can modify the budget but after the modification the sum of all the budget elements percentages must be 100% or 0% if there are no elements in the budget.

How can I include this constraint in my model? enter image description here
The model can also be found here

4

2 回答 2

3

您应该只对contains属性施加约束。在 MagicDraw 中,可以显示约束的标签或 OCL 中的实际约束。

这是一个仅带有标签的示例,它可能更适合概念模型的受众:

在此处输入图像描述

以下是 OCL 的示例:

在此处输入图像描述

可读性差一点,嗯?

于 2016-02-11T22:22:26.847 回答
2

只需将这样的约束附加到Budget

在此处输入图像描述

如果您的工具不提供本机约束元素,您可以简单地使用注释并将约束放在大括号中。

于 2016-02-11T22:13:12.397 回答