| PSICS Fall 2004 Quiz #9 |
|   PSICS Home   |   Description |
Submit your solutions to this quiz by dropping in your webct drop box in the box labeled "Quiz9". Let Dave know if you have problems submitting!
| Assignment |
Write a function named play-number-game that displays
a window in which the user can play a simple number guessing game. The
user is allowed to submit guesses by typing a number in a textbox and
pressing a button. Each time the user submits a guess the GUI should
update a status message that indicates whether the guess is invalid,
too low, too high or correct.
The function play-number-game is passed a number in
the range 0-100, this number is the actual answer used by the game.
For example, if the function is called like this:
(play-number-game 87)
The user must try to guess the number 87. The game can also be called like this:
(play-number-game (floor (random 101)))
to use a random number as the correct answer.
The required functionality:
The game should not display a window unless an integer between
0 and 100 (inclusive) is passed as the correct answer parameter. In
this case you can use the error function to generate an
error message that displays in DrScheme.
If a valid number is passed to play-number-game, a
window should pop up and allow the user to play the game.
Initially the GUI should display some instructions, for example:

If the user enters something that is not a number, the game must tell them so:

If the user enters a number that is lower than the correct answer, or higher than the correct answer, the game must tell them so:

If the user guesses the right number, the game must say so:

IMPORTANT! You must provide the function
play-number-game (don't just write some code that allows
the user to play the game without calling
play-number-game).