Welcome to Dream.In.Code
Become a Java Expert!

Join 149,534 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,516 people online right now. Registration is fast and FREE... Join Now!




family tree using java

 
Reply to this topicStart new topic

family tree using java

aissamt
27 May, 2007 - 10:15 AM
Post #1

New D.I.C Head
*

Joined: 27 May, 2007
Posts: 2


My Contributions
i have a project to constract a family tree using java, i tried to do it , but no chance, if you have any clues on how to do it, please post it, thx
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Family Tree Using Java
27 May, 2007 - 10:34 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,303



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
It would be better if you post the code that you completed in your attempt to fulfill your project.

We do not provide code just for the asking, we help you understand what is wrong with your code.
User is offlineProfile CardPM
+Quote Post

aissamt
RE: Family Tree Using Java
27 May, 2007 - 02:32 PM
Post #3

New D.I.C Head
*

Joined: 27 May, 2007
Posts: 2


My Contributions
all i need is how to do the find methode, since every node in the tree can have many children ( so i used an array for it) but now i can't figure a way to search the whole tree for a specific node.
User is offlineProfile CardPM
+Quote Post

oubless
RE: Family Tree Using Java
28 May, 2007 - 07:08 AM
Post #4

New D.I.C Head
*

Joined: 28 May, 2007
Posts: 23


My Contributions
QUOTE(aissamt @ 27 May, 2007 - 03:32 PM) *

all i need is how to do the find methode, since every node in the tree can have many children ( so i used an array for it) but now i can't figure a way to search the whole tree for a specific node.

- consider using java.util.List instead of array.
- about the search method:
Make it recursive, something like ( this will probably NOT work as is )
CODE

public Node find(Node nodeToFind){
  Node tmp;
  if( this.equals(nodeToFind) )
     return this; // found - this one
  for( Node child : childrenNodes ){
    tmp = child.find(nodeToFind);
    if( tmp != null ) // found in some of the children nodes
       return tmp;
  }
  return null; //not found
}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:07PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month