import java.util.Random; // needed for Random 
public class Lab21Driver
{
   public static void main (String [] args)
   {
		      // object and variable declarations
      LinkedListLab21 myLinkedList; 
      Random myRandom;
      int value;
      boolean answer,found;  
         
			    // object instantiations
      myRandom = new Random();
      myLinkedList = new LinkedListLab21();
          
				  // checking empty list for 0
      answer = myLinkedList.isHere(0);
      System.out.print (" since list is empty, expected: false ");
      System.out.println ("actual output: " + answer);
      System.out.println ();
      	
      	// generating 10 random integers in the range of -50 to +50
  		   // and inserting them in list, keeping list in ascending order
       value = myRandom.nextInt(101); // between 0 (inclusive) and 101 (exclusive) 
       for (int i = 0; i < 10; i++)
       {
         value = value - 50;  // sliding numbers left along number line
         System.out.println (" Inserting: " + value);
         myLinkedList.insert (value);
         System.out.println (myLinkedList); // using toString method
         System.out.println();
			value = myRandom.nextInt(101);  // generating next number
      } // end for
      	
      found = false;  // haven't looked so haven't found
      while (!found)
      {
         value = myRandom.nextInt(101);
         value = value - 50;
         answer = myLinkedList.isHere (value); // in list or not
         System.out.print ( value  + " in list is  "); // output result
         System.out.print (answer + " - Here's proof: " );
         System.out.println (myLinkedList); // shows value is/isn't there
 			System.out.println();
 
         if (answer)  // if value found, delete it
         {
            System.out.print ("deleted " + value + " from list " +
				   " - Here's proof:  " );
            myLinkedList.deleteNode(value) ; 
            found = true;
            System.out.println (myLinkedList); // using toString
         }
            System.out.println();
         }// end while
      	
      } // end main
   } // end Lab21Driver	
