How to indicate a list of types in a Class Diagram

倖福魔咒の 提交于 2019-11-28 08:59:06

问题


As the problem states, I am trying to indicate 'multiple' of a type in a Class Diagram- for example, my Class is a lecture:

Lecture

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

回答1:


Create an association between Lecture and Student. On the student end of the association, create an association end called "studentsAttending" having a multiplicity of 0..*. (I recommend you call that association end "attendingStudent" to be consistent with standards such as ISO 11179, BTW.)

You should probably give the other end of the association a name also, like "attendedLecture", with a multiplicity of 0..*.

Here's an example:

These association ends are properties, owned either by the class on the opposite side of the association or owned by the association. Here's some evidence of this from a UML 2 compliant tool:

When the max cardinality is > 1, the property typically gets a type that is some kind of collection in the technology. For an example in Java: List<Student> attendingStudent. (Although in the technology layer, I prefer to pluralize such properties, which would make that List<Student> attendingStudents.)



来源:https://stackoverflow.com/questions/33985491/how-to-indicate-a-list-of-types-in-a-class-diagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!