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

Filed under:
|

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

Related posts about java

Related posts about family-tree

  • public family tree

    as seen on Super User - Search for 'Super User'
    Hi all Does anyone know a ancestry site that allows you to create a public profile or tree, so that other visitors can see your family tree. In all sites that I have found (dynastree.com, familylink.com, ancestry.com, genebase.com), if someone wants to see your family tree, they must be members or… >>> More

  • Logic for family tree program

    as seen on Stack Overflow - Search for 'Stack Overflow'
    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… >>> More

  • Family Tree :- myheritage.com

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hello, The other day i just accidently visited the site myheritage.com. I was just wondering, how they must have created one? Can anybody tell me what can be their database design? and if possible, algorithm that we can use to generate such a tree? Generating simple binary tree is very easy using… >>> More

  • Prolog Family tree

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi I have a Question in prolog , I did it but its not showing answers When i ask about the brothers,sisters,uncles,aunts This is what I wrote, what's wrong ? /*uncle(X, Y) :– male(X), sibling(X, Z), parent(Z, Y).*/ /*uncle(X, Y) :– male(X), spouse(X, W), sibling(W, Z), parent(Z, Y).*/ uncle(X… >>> More

  • SQL Loop over a family tree

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Using SQL server 2008. I have a family tree of animals stored in a table, and want to give some information on how 'genetically diverse' (or not) the offspring is. In SQL how can I produce sensible metrics to show how closely related the parents are? Perhaps some sort of percentage of shared blood… >>> More