Logic for family tree program
Posted
by
david robers
on Stack Overflow
See other posts from Stack Overflow
or by david robers
Published on 2010-12-26T18:52:28Z
Indexed on
2010/12/26
20:53 UTC
Read the original article
Hit count: 275
java
|family-tree
Hi All,
I am creating a family tree program in Java, or at least trying to. I have developed several classes:
- Person - getters and setter for name gender age etc
- FamilyMember - extends Person getters and setters for setting arents and children
- Family - which consists of multiple family members and methods for adding removing members
- FamilyTree which is the main class for setting relationships.
I have two main problems:
1) I need to set the relationships between people. Currently I am doing:
FamilyMember A, FamilyMember B
B.setMother(A);
A.setChild(B);
The example above is for setting a mother child relationship.
This seems very clunky. Its getting very long winded to implement all relationships. Any ideas on how to implement multiple relationships in a less prodcedural way?
2) I have to be able to display the family tree. How can I do this? Are there any custom classes out there to make life easier?
Thanks for your time...
© Stack Overflow or respective owner