nus-cs2103-AY2122S2 / forum

13 stars 1 forks source link

Use of roles and navigability in class diagram #294

Closed jxt00 closed 2 years ago

jxt00 commented 2 years ago

Hello, would like to clarify my doubts on this.

These diagrams and codes are taken from the textbook sections Roles and Navigability.

  1. Given that Man and Woman each contains references to each other, would it be acceptable to add bidirectional arrows to the class diagram? (i.e similar to the ones in the Dog and Man UML.)
  2. Would it also be acceptable to add the roles (e.g. pet and owner) to the Dog and Man UML?
  3. Is it acceptable to use both roles and navigability in a single class diagram? (I do not think they are inter-changeable right?)

Thank you!

image

class Man {
    Woman wife;
}

class Woman {
    Man husband;
}

image

class Dog {
    Man man;
    // ...
}

class Man {
    Dog dog;
    // ...
}
damithc commented 2 years ago

@jxt00 Yes to all three questions.

jxt00 commented 2 years ago

Thank you prof!