/** This class contains static methods for playing a game in
    which the player tries to guess a randomly chosen number.
*/

public class GuessMyNumber {
   /** The class invariant consists of the definitions of the four
       fields. These definitions are true whenever one of
       the methods is called, and it is the responsibility of every
       method to keep them true. So look at these fields and their
       definitions when writing the methods! */
    
   /** The integer the program chooses.
       myNumber is null if the player has not yet chosen a number */
    private static Integer myNumber;
    
    /** The number of guesses the player has attempted. */
    private static int numGuesses= 0;
    
    /** The range of guesses should be 1..maximum */
    private static int max;
    
    /** = "the player has guessed the correct number". */
    private static boolean playerGuessedMyNumber= false;

   /**Put your method guess() here. Write the specification and header first
      with an empty body, i.e. "{ }". Then compile it. When it is syntactically
      correct, then begin implementing the method body. Please program and
      test incrementally. Write part of the method body and test it. When you
      are completely satisfied that that part is correct, do the next part. Etc. */

    

    

  

    

    /**Put method rateMe() here. Write the specification and header first,
     with an empty body, i.e. "{ }". Then compile it. When it is syntactically
     correct, then begin implementing the method body. Please program and
      test incrementally. Write part of the method body and test it. When you
      are completely satisfied that that part is correct, do the next part. Etc.
     */

   

    

   

/** Choose an integer between 1 and n --print an error message
     and return if n is < 1. */
    public static void chooseNumber(int n) {
        if (n < 1) {
            System.out.println("The integer has to be > 0. Please " +
                               "choose another integer");
            return;
            
        }
        int random= 1 + (int) (n * Math.random());
        myNumber= new Integer(random);
        max= n;
        numGuesses= 0;
        playerGuessedMyNumber= false;
        System.out.println("Okay, I've chosen a number between 1 and " + 
                           n + ". Try to guess it!");
    }

}