Draw a Sequence Diagram for the code (PersonList
, Person
, Tag
)
Consider the code below:
class Person {
Tag tag;
String name;
Person(String personName, String tagName) {
name = personName;
tag = new Tag(tagName);
}
}
class Tag {
Tag(String value) {
// ...
}
}
class PersonList {
void addPerson(Person p) {
// ...
}
}
Draw a sequence diagram to illustrate the object interactions that happen in the code snippet below:
PersonList personList = new PersonList();
while (hasRoom) {
Person p = new Person("Adam", "friend");
personList.addPerson(p);
}
How would you update the diagram if the PersonList
class was updated as follows?
class PersonList{
void addPerson(Person p){
add(p);
}
void add(Person p){
//...
}
}