Results 1 to 3 of 3
Thread: Tree structure using JAVA
- 08-01-2007, 04:10 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
- 08-02-2007, 02:50 PM #2
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
You could implement this using a simple class structure:
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 :Java 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); } }
instead.Java Code:private Person mother; private Person father;
Hope this gets you started. :)
- 05-27-2010, 11:02 AM #3
Member
- Join Date
- May 2010
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
Binary Tree Implementation in Java
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:35 PM -
Stack data structure in Java
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:34 PM -
Java Grapical Tree
By Deo Favente in forum Reviews / AdvertisingReplies: 3Last Post: 02-18-2008, 06:12 AM -
Java Array of Structure
By PAffiliates in forum New To JavaReplies: 1Last Post: 01-28-2008, 06:08 AM -
Implementing a red-black tree in java
By baltazar in forum New To JavaReplies: 1Last Post: 07-13-2007, 08:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks