/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package trees;

/**
 *
 * @author kvaradar
 */
public class MyTree<E> implements Tree<E> {

   private int size;
   private TreeNode<E> root;

   public MyTree() {
       root = null;
       size = 0;
   }

   /* I have added the methods addRoot and addChild so that
    * I can construct a tree on which you can test the methods
    * you write. These two methods are not as robust as they
    * can be, but will do for this particular purpose.
    */
   public Position<E> addRoot(E e) {
       // Create a node with e, make it the root, and return the position
       TreeNode<E> t = new TreeNode(e,null);
       root = t;
       size = 1;
       return t;
   }

   public Position<E> addChild(Position<E> v, E e) {
       // Create a node with e, add it as a child of v, and return new position
       TreeNode<E> w = (TreeNode<E>) v;
       TreeNode<E> t = new TreeNode(e, w);
       w.addChild(t);
       size++;
       return t;

   }


   
   public int size() {return size;}

}
