repl.it
linkExplain Class Diagram
Explain the associations, navigabilities, and multiplicities in the class diagram below:
Guidance for the item(s) below:
[Image source: this article]
That is why we have structured these tutorials to get everyone to practice this skill so that your first few (not so good) diagram drawing experiences happen in the tutorial, not in an interview or during your internship.
Draw an Object Diagrams for the Class Diagram (Person-Guardian)
Suppose we wrote a program to follow the class structure given in this class diagram:
Draw object diagrams to represent the object structures after each of these steps below. Assume that we are trying to minimize the number of total objects.
i.e. apply step 1 → [diagram 1] → apply step 2 on diagram 1 → [diagram 2] and so on.
There are no persons.
Alfred
is the Guardian of Bruce
.
Bruce
's contact number is the same as Alfred
's.
Alfred
is also the guardian of another person. That person lists Alfred
s home address as his home address as well as office address.
Alfred
has a an office address at Wayne Industries
building which is different from his home address (i.e. Bat Cave
).
After step 2, the diagram should be like this:
Draw Class Diagram for Box etc.
Draw a class diagram for the code below. Show the attributes, methods, associations, navigabilities, and multiplicities in the class diagram below:
class Box {
private Item[] parts = new Item[10];
private Item spareItem;
private Lid lid; // lid of this box
private Box outerBox;
public void open(){
//...
}
}
class Item {
public static int totalItems;
}
class Lid {
Box box; // the box for which this is the lid
}