nus-cs2103-AY2324S2 / forum

17 stars 0 forks source link

Practice exam part two UML diagram #1024

Open Li-Zizhen opened 2 months ago

Li-Zizhen commented 2 months ago

If the array list is treated as a single instance, how do we show the multiplicity in class diagram? image

Moreover, since the implementation of UiWidget is not given in the questions, how do we know if it contains reference to activities? Making this two-way arrows instead of single arrow? image

baskargopinath commented 2 months ago

To show multiplicity for lists u can put the number of possible objects in the list so like 0..*

damithc commented 2 months ago

To show multiplicity for lists u can put the number of possible objects in the list so like 0..*

Technically, you can. There is an example is the UML reference sheet. image

But we have never used this notation anywhere else is in course; so, will not be examined.

damithc commented 2 months ago

If the array list is treated as a single instance, how do we show the multiplicity in class diagram? image

@Li-Zizhen Data structures such as lists are not shown in class/object diagrams because their main purpose is give us the ability to keep more than one object. So, a multiplicity such as * or 0..5 in a class diagram already indicates the use of some kind of 'collective' data structure, without needing to show the data structure as a separate class. In an object diagram, just omit the list object and simply connect to the objects inside the list.

Moreover, since the implementation of UiWidget is not given in the questions, how do we know if it contains reference to activities? Making this two-way arrows instead of single arrow? image

Just show what is known. Code not given means the code is not relevant to the answer :-)