import java.util.*;

public class SBTree implements SBTreeInterface
{
   private AState state;
   
   // constructor
   public SBTree()
   {
      state = EmptyTree.singleton();
   }       
   
   public SBTree(Object obj)
   {
      state = new NonEmptyTree(obj);
   }
   // get the data stored in the current node
   public Object getData( )   
   {
      return (state.getData());
   }

   public SBTree getLeft( )
   {
      return (state.getLeft());                                              
   } 
   
   public SBTree getRight( )
   {
      return (state.getRight());                                               
   } 


   public void setData(Object obj)   
   {
      state.setData(obj, this);
   }                                                               
   

   public void setLeft(SBTree lft)
   {                    
      state.setLeft(lft);
   }

   public void setRight(SBTree rgt)
   {                    
      state.setRight( rgt);
   }  


   public Object acceptVisitor(SBVisitor outsider, Object inp)
   {  
      // callback visitor
      return (state.acceptVisitor(outsider, inp,this));
   }

   public AState getState()
   {
      return state;
   }
   
   public void changeState(AState a)
   {
      state = a;
   }
}
           



