Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2007, 05:10 PM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
Tree structure using JAVA
Hi, Where can I find the example of Tree structure using JAVA ?
I would like to do a family tree by using Java. but I have no idea.

Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-02-2007, 03:50 PM
Member
 
Join Date: Jul 2007
Location: England, Bath
Posts: 47
shanePreater is on a distinguished road
You could implement this using a simple class structure:
Code:
public class Person { private List<Person> parents; private List<Person> children; ... public void addParent(Person parent) { this.getParents().add(parent); parent.getChildren().add(this); } public void addChild(Person child) { this.getChildren().add(child); child.getParents().add(this); } }
Obviously you will need to implement the getters and setters for the lists but that will allow you to construct your family tree. Also you may wish to limit the parent list to 2 entries or change this for :
Code:
private Person mother; private Person father;
instead.

Hope this gets you started.
__________________
Shane Preater -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binary Tree Implementation in Java Java Tip java.lang 0 04-16-2008 11:35 PM
Stack data structure in Java Java Tip java.lang 0 04-16-2008 11:34 PM
Java Grapical Tree Deo Favente Reviews / Advertising 3 02-18-2008 07:12 AM
Java Array of Structure PAffiliates New To Java 1 01-28-2008 07:08 AM
Implementing a red-black tree in java baltazar New To Java 1 07-13-2007 09:37 PM


All times are GMT +3. The time now is 03:28 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org