
/*
 * ReverseList test program
 *
 * burton rosenberg
 * 20 Sept 2001
 *
 * inserts words in words array to tail or head 
 * of an initially empty list,
 * each line of test input is added to the linked list,
 * at the head if line begins with character '-', else
 * at the tail
 *
 */

// this import required for Buffered Reader, etc.
import java.io.* ;

class ReverseListTest
{

   public static void main( String [] args )
   {

       BufferedReader br = new BufferedReader( 
                             new InputStreamReader(
                                 System.in) ) ;
       LinkedList3 ll = new LinkedList3() ;
       ll.reverseList() ;
       ll.printList() ;

       try 
       {
          String newWord ;
          while ( (newWord = br.readLine()) != null ) 
          {
              if ( newWord.length()<1 ) break ;
              // newWord.charAt(0) exists
              if ( newWord.charAt(0)=='-' )
              {
                 // insert at head
                 System.out.println("insertAtHead: "+newWord) ;
                 ll.insertAtHead( newWord ) ;
              }
              else
              {
                 // insert at tail
                 System.out.println("insertAtTail: "+newWord) ;
                 ll.insertAtTail( newWord ) ;
              }
              System.out.println("printList:") ;
              ll.printList() ;
              System.out.println() ;
          }
       } catch ( IOException ioe ) {}
       ll.reverseList() ;
       System.out.println("reverseList:") ;
       ll.printList() ;

   }
}

