CSC 222: Computer Programming II
Spring 2005

HW1: Java Review

For this first assignment, you will write a Java program that plays an interactive guessing game with the user. Your program should begin by prompting the user to enter the low and high limits on the guessing range. For example, if the user enters 1 and 100 as the limits, then the program will pick a random integer between 1 and 100 (inclusive) for the user to guess. Once the number has been selected, the program shjould repeatedly prompt the user for a guess and display whether that guess was correct, too high, or too low. When the number is finally guessed correctly, a message containing the number of guesses should be displayed.

The following is sample output that might be produced by your program (with user input in bold):

Enter the low and high limits for the game: 1 100

Enter a guess (between 1 and 100): 50
  Your guess of 50 was TOO HIGH
Enter a guess (between 1 and 49): 25
  Your guess of 25 was TOO HIGH
Enter a guess (between 1 and 24): 12
  Your guess of 12 was TOO LOW
Enter a guess (between 13 and 24): 18
  Your guess of 18 was TOO HIGH
Enter a guess (between 13 and 17): 15
  Your guess of 15 was TOO HIGH
Enter a guess (between 13 and 14): 14
  Your guess of 14 was CORRECT

You got the number in only 6 guesses.

In completing this assignment, you must implement a class named GuessRange that encapsulates the state and operations associated with a guessing range. See the accompanying javadoc documentation for a description of this class and the methods it must provide. The high-level workings of the game should be defined in the main method of a separate class named GuessingGame.

Your grade for this assignment will be partially based on the readability of your code. A class style guide has been provided which describes the expectations for all assignments in this class.