Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Simple Family Tree in Java

$
0
0
OK, so I need help on an assignment. I'm still in the process of reading up on how to go about it, but I thought I would post here to get other suggestions.

I need to create a simple family tree program that runs from console. I do not need to save or load the tree at all as it's all created in the instance of the program.

Basically, here's what needs to be done:

- The user is asked to supply the name of the first ancestor, then the name of the partner.
- Now the user is presented with a menu, one option to add a child to the current couple, and one to view the tree so far.

The big part I need help on is creating the FamilyTreeNode, which holds information on the family member's name, then 3 nodes underneath which reference the partner, the siblings, and the children. I have this so far, but I don't know how to create a new node for each family member, and add that information to the nodes.

public class FamilyTreeNode
	{
		// Identifier attribute
		public String name;
		public FamilyTreeNode partner;
		public FamilyTreeNode sibling;
		public FamilyTreeNode child;
	}



Could anybody suggest a way to do this?

Many thanks.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>