nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Practice Exam Qn 12 #479

Closed bangyiwu closed 3 years ago

bangyiwu commented 4 years ago

I am quite confused on why the multiplicity of door must be one. The object diagram does not show any information regarding the door class.

Screenshot 2020-11-27 at 11 03 35 PM
damithc commented 4 years ago

Take each class diagram, and ask yourself "can the given object diagram result from this class diagram?" The answer for a and b is "yes" but it's "no" for c. The reason why the object diagram could not have come from c is because c requires every Table object to be linked to exactly one Door object.

GeNiaaz commented 4 years ago

So because no data is given about door in the original diagram, to assume it is anything (or *) would be a correct assumption, regardless if there is actually an association or not?

wltan commented 4 years ago

I wouldn't say that it is assumed to be *, but because nothing is connected to Door in the object diagram, any class diagram that mandates an association with Door is immediately wrong (in this case (c)).

damithc commented 4 years ago

I wouldn't say that it is assumed to be *, but because nothing is connected to Door in the object diagram, any class diagram that mandates an association with Door is immediately wrong (in this case (c)).

Yes, that's the reason. Note the following:

  1. We are trying to figure out if a given object diagram could have come from the given class diagram (once for each class diagram given).
  2. If the class diagram has a rule that is violated by the object diagram, it could not have come from that class diagram.
  3. An object diagram may not have objects of every class that is in the class diagram. For example, when you start your iP application with no data, it will not have any Deadline objects although the Deadline class is in the class diagram of the iP. As long as the object diagram doesn't violate any rules in the class diagram, it could have come from that class diagram.
GeNiaaz commented 4 years ago

I wouldn't say that it is assumed to be *, but because nothing is connected to Door in the object diagram, any class diagram that mandates an association with Door is immediately wrong (in this case (c)).

So am I right to say that in b, because the multiplicity is anything that it could also mean they are not associated with each other too? We just unsure at that point so anything is still plausible

damithc commented 4 years ago

So am I right to say that in b, because the multiplicity is anything that it could also mean they are not associated with each other too? We just unsure at that point so anything is still plausible

hmmm... multiplicity * near the Door (in the class diagram) means a givenTable object (in the object diagram) can be connected to any number of Door objects, including zero Door objects i.e., a Table can exist without being connected to a Door at all.

GeNiaaz commented 4 years ago

So am I right to say that in b, because the multiplicity is anything that it could also mean they are not associated with each other too? We just unsure at that point so anything is still plausible

hmmm... multiplicity * near the Door (in the class diagram) means a givenTable object (in the object diagram) can be connected to any number of Door objects, including zero Door objects i.e., a Table can exist without being connected to a Door at all.

Alright that clears it up, thanks