nus-cs2103-AY2324S2 / forum

16 stars 0 forks source link

Optional attribute in class diagram #1058

Open Li-Zizhen opened 5 months ago

Li-Zizhen commented 5 months ago

Why is C wrong? The attribute in chair is optional, it can choose not to show its attribute table.

image

jannaleong commented 5 months ago

in the class diagram, there is no association between chair and table class. If they had left out attribute in chair, there needs to be a line between the 2 classes.

As the object diagram shows there is an associaiton, this class diagram in c is not compliant.

Li-Zizhen commented 5 months ago

@jannaleong Thank you for your response. So if we omit the attribute, we much show the association line instead? image

drustanyjt commented 5 months ago

I don't think that's the main focus. In the Class Diagram you highlighted, there is no association line being drawn between Chair and Table, hence there should be no associations between Chair and Table. This means that the object diagram is incorrect (because it IS showing an association between the Chair and Table)

Li-Zizhen commented 5 months ago

Sorry for that.

Showing attributes is the same as the association line. Therefore, we can use attributes instead of association lines. However, attributes can also be omitted.

Therefore, if we use attributes instead of the association line and then omit that attribute(consider it as not important), we can just not show it right?

ThatGirlJam commented 5 months ago

I suppose that's true, but since this question seems to be specific to the object diagram given, where it was deemed important to have that association between Chair and Table, c is less likely to be a correct option.

damithc commented 5 months ago

I suppose that's true, but since this question seems to be specific to the object diagram given, where it was deemed important to have that association between Chair and Table, c is less likely to be a correct option.

Yup, if it was relevant to the answer, it wouldn't have been omitted as 'not important'.