

/**
 * GuesserLoadSave.java
 *
 *
 * Created: Tue Oct 15 21:40:28 2002
 *
 * @author <a href="mailto:bina@cse.buffalo.edu "</a>
 * @version
 */
import java.util.*;
import java.io.*;
import javax.swing.*;

public class GuesserLoadSave {
   public static Visitor loader = new LoadVisitor(); 
   public static Visitor player = new PlayVisitor();
   public static Visitor saver = new SaveVisitor();
  
   public static void main (String[] args) throws java.io.IOException {

      BTree itemDB = new BTree();

      //load tree from stored data
      itemDB = (BTree)itemDB.acceptVisitor(loader, null);

      // main control loop: play the guessing game
      while (true) {
      String item = (String)itemDB.acceptVisitor(player, null);
      System.out.println(item);
      int n1 = JOptionPane.showConfirmDialog(null,
						"Want to continue playing",
						null,
					       JOptionPane.YES_NO_OPTION);
      if ( n1 == JOptionPane.NO_OPTION) 
	    break;
      }
      // store the knowledge gathered in a file using object serialization
      itemDB = (BTree)itemDB.acceptVisitor(saver, null);

      System.exit(0);
   }
   
}// GuesserLoadSave
