Composites

In the ABC business model an organization consists of many members.

A member may have a spouse and children.

Of course the spouse and children of a member may also be members or they may simply be dependants.

Every dependant must be sponsored by exactly one member.

All persons, whether members or dependants, have the following attributes:

last name

first name

dob (date of birth)

gender (male/female)

id (a unique identification string)

All persons have a toString method that returns these attributes as a nicely formatted string.

A member's spouse and children may be members or dependants.

Use the Composite Pattern to design and implement this part of the ABC business model.

Begin be sketching a UML class diagram.

Next, translate your sketch into a Java implementation.

Provide a displayDependants method in the Organization classes that displays all dependants of members in the organization and their sponsors (use the toString method above).

Test your implementation by declaring a class called TestOrganization. The main method of this class creates an organization and populates it with various members and dependants described in org1.xml. Finally, call the displayDependants method.