Tut 10 - Class and Object Diagrams
Problems
01. Interpret a Class Diagram
02. Draw an object diagram
1
2

3

4

5

03. Draw a Class Diagram

Tips
Last updated





Last updated
class Person {
private String name;
private Address home; // Required (multiplicity 1)
private Address office; // Optional (multiplicity 0..1)
private List<ContactNumber> contacts; // The 'ContactNumber' association
// The constructor FORCES you to provide a home address
public Person(String name, Address homeAddress) {
this.name = name;
if (homeAddress == null) {
// This is good practice to prevent errors
throw new IllegalArgumentException("A Person must have a home address.");
}
this.home = homeAddress;
// Note: 'office' is left as null, which is valid (0..1)
}
public String getName() {
return this.name;
}
// ...
}