【问题标题】:How to indicate a list of types in a Class Diagram如何在类图中指示类型列表
【发布时间】:2015-11-29 17:08:07
【问题描述】:

正如问题所述,我试图在类图中指示“多个”类型 - 例如,我的类是讲座:

Lecture

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

【问题讨论】:

标签: list uml class-diagram


【解决方案1】:

在 Lecture 和 Student 之间建立关联。在关联的学生端,创建一个名为“studentsAttending”的关联端,其重数为 0..*。 (我建议您将该关联端称为“attendingStudent”以符合 ISO 11179、BTW 等标准。)

您可能还应该为关联的另一端命名,例如“attendedLecture”,其重数为 0..*。

这是一个例子:

这些关联端属性,由关联对面的类拥有或由关联拥有。以下是来自符合 UML 2 的工具的一些证据:

当最大基数 > 1 时,该属性通常会获得一种类型,该类型是技术中的某种集合。对于 Java 中的示例:List<Student> attendingStudent。 (虽然在技术层面,我更喜欢将这些属性复数化,这样List<Student> attendingStudents。)

【讨论】:

    猜你喜欢
    • 2020-01-11
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    • 2022-07-28
    • 2021-12-18
    • 1970-01-01
    相关资源
    最近更新 更多