public class GameBinaryTree{ public static final int TO_ROOT =0; public static final int TO_LEFT =1; public static final int TO_RIGHT=2; private TreeNode root; //of tree private TreeNode current; //position in tree private int size; //of tree private TreeNode tempNode; public GameBinaryTree(){ //default constructor root = null; //korrekte manier? current = null; //ditto size = 0; } public void insert(Object element, int position){ TreeNode newTreeNode = new TreeNode(element); if (position == 0) { if (root == null) this.root = newTreeNode; } else if (position == 1) current.setLeft(newTreeNode); else if (position == 2) current.setRight(newTreeNode); } //Inner class that implements a node in the tree. Each node has elemente of type Object, left and right children, and a parent pointer public class TreeNode{ private Object element; private TreeNode left; private TreeNode right; private TreeNode parent; //default constructor - set the element to paramater 'element' and other fields to null public TreeNode(Object element){ this.element = element; left = null; right = null; //parent = null; //reg om parent na null te sit? } //set left child node element public void setLeft(TreeNode to_left){ left = to_left; } } public class Test { private GameBinaryTree$TreeNode node; public Test(){ } public static void main(String args[]) { GameBinaryTree gameBT = new GameBinaryTree(); Test tst = new Test(); gameBT.insert(new Integer(args[0]),0); gameBT.insert("1",1); gameBT.insert(new Integer(args[2]),2); tst.node = gameBT.getCurrentNode(); gameBT.insert(new Integer(args[3]),1); gameBT.insert(new Integer(args[4]),1); gameBT.insert(new Integer(args[5]),1); // gameBT.printFromRoot(); System.out.println(gameBT.getCurrentNodeElement()); System.out.println(gameBT.getNodeElement(tst.node)); } }