如何在 Class 图中指示类型列表

How to indicate a list of types in a Class Diagram

如问题所述,我试图在 Class 图中指示 'multiple' 类型 - 例如,我的 Class 是一个讲座:

Lecture

topic : String
lecturer : String
timeStart : Time
studentsAttending : **Insert indication of list of students here**

创建讲座和学生之间的关联。在关联的学生端,创建一个名为 "studentsAttending" 的关联端,其重数为 0..*。 (我建议您将该关联命名为 "attendingStudent" 以与 ISO 11179 等标准保持一致,顺便说一句。)

您可能还应该给关联的另一端起一个名称,例如 "attendedLecture",重数为 0..*。

这是一个例子:

这些协会末端 财产,由协会对面的 class 拥有或由协会拥有。下面是来自 UML 2 兼容工具的一些证据:

当最大基数 > 1 时,属性 通常会获得一种类型,即技术中的某种集合。例如 Java:List<Student> attendingStudent。 (虽然在技术层,我更喜欢将这样的属性复数化,这样就可以List<Student> attendingStudents了。)