   import java.util.Scanner;
   import java.util.Random;


// Lottery
    public class Lottery
   {
    // attributes include the lottery array of 5 numbers
    //            and the user's array of 5 numbers
      int [] userChoices;
      int [] spin;
   
   // constructor accepts the seed as a parameter
   // constructs a Random object
   // loops to generate 5 numbers in the range 0..9 
   //   stores each number generated in the lottery array
   // calls runLottery method
       public Lottery (int mySeed)
      {
         Random aSpin;
         aSpin = new Random (mySeed);
         this.spin = new int  [5];
      	
         for (int i = 0; i<= 4; i++)
         {
            spin[i] = aSpin.nextInt(10);
            System.out.print(" spin[" + i + "] = " + spin[i]);  // DEBUG
         }	
         runLottery();
      } // END CONSTRUCTOR
   
   // run lottery method
       public void runLottery ()
      { 
         int numberMatches;
         boolean winner;
      
      	//   calls get user's numbers
         this.userChoices   =  getUserNumbers();
      
         numberMatches =   compareArray (this.userChoices, this.spin);
      	//   calls determine winner checks whether number of matches equals 5 or not
         if (numberMatches == 5) 
         {
            System.out.println (" You won the lottery ");
         }
         else
         {
            System.out.println (" Sorry, you did not win. Better luck next time ");
         }   
      //       winner = determineWinner (numberMatches);
      
      	//   calls show array two times
      	//        once with lottery array
      	//        once with user's array
            showArray (this.userChoices, this.spin);
      //		 showArray (spin);
      
      	//   prints ending messages
      //      printEndingMessages(winner);
      
      }//  end runLottery
   
       public int[] getUserNumbers()
      {
      		// prompt user for 5 numbers 1 at a time in range 0 to 9
         int temp;
         Scanner kboard;
         int i;
         kboard = new Scanner (System.in);
         i = 0;
         this.userChoices = new int [5];
      				// use a loop to pick up the numbers
         while (i <= 4) 
         {
         			// pick up each value user enters  make sure it's in range
            System.out.println ("Please enter a digit in the range 0 to 9");
            temp = kboard.nextInt();
            if (temp >= 0 && temp <= 9)
            {
               System.out.println (" you entered "  + temp);   //DEBUG
               this.userChoices[i] = temp;
               i++;
            } // end if
         } // end while			     
         return this.userChoices; 
      } // END getUserNumbers
   
   //    compare user's array with lottery array  counts matches
      
       public int compareArray (int [] yours, int [] theirs)
      {
         int numberMatches;
         numberMatches = 0;
         
         for (int i = 0; i <= 4; i++)
         {
            if (yours[i] == theirs[i])
               numberMatches++;
         }// END FOR
         return numberMatches;
      } // END compareArray
   
       public void showArray (int [] yours, int [] theirs)
      {
         System.out.println ("  Your Numbers            Lottery Numbers ");
         System.out.println (" ________________________________________");
         for (int i = 0; i <= 4; i++)
         {  
            System.out.println(yours[i] + "             " + theirs[i]);  
         }// END FOR
      }// END showArray	   
   
   }  // end class Lottery
