
/**
 * LearnVisitor.java
 *
 *
 * Created: Fri Oct 25 22:41:20 2002
 *
 * @author <a href="mailto: "</a>
 * @version
 */
import javax.swing.JOptionPane;

public class LearnVisitor implements Visitor{
   public LearnVisitor (){
      
   }
   public Object operation(Object host, Object inp)
   {
      BTree bt = (BTree)host;
      
   //what are you thinking of? input data
      String newItem =
         JOptionPane.showInputDialog 
	 ("Enter the entity you are thinking about");
   // give a question that distinguishes this from node data
      String ques =
         JOptionPane.showInputDialog 
	 ("Enter a question that gives yes answer for " + newItem +
	  " and no for "+ bt.getData() );  

   //build a tree with this question as root, old leaf as left, new
   //data as right
      Object root = bt.getData(); 
      bt.setData(ques);
      bt.setLeft(new BTree(root, null, null));
      bt.setRight(new BTree(newItem,null, null));
      return newItem;
   }
}// LearnVisitor

