CSci 211: File Systems
Fall Semester 1996
Assignment #4


Due Date

Wednesday, December 4, 1996.

Objective

To give you practice in the implementation a simple graphical user interface.

Assignment

This is essentially exercise 10.24 from the book Java: How to Program by Deitel and Deitel (Prentice Hall, 1997).

Write a Java program that plays "guess the number" as follows: Your program chooses a number at large in the range 1-1000 (use Math.random()). The program then displays the label:

    I have a number between 1 and 1000.  Can you guess the number?
    Please enter your first guess.
A text field should be used to input the guess.

As each guess is input, the background color should change to either red or blue. Red indicates that the user is getting "warmer" and blue indicates that the user is getting "colder".

A second non-editable text field should display either "Too High" or "Too Low" to help the user zero in on the correct answer. When the user guesses the correct answer "Correct!" should be displayed. When the user guesses the correct answer, the text field used for input should be changed to non-editable.

A button should be provided to allow the user to play the game again. When the button is clicked, a new random number should be generated and the first text field changed to editable.

I may provide more information on the layout of the interface elements later.

You may make this program either an application or an applet. You may add other features if you want.

Submitting Your Assignment

Once you have completed the program:


UP to CSci 211 Assignments page?


Copyright © 1996, H. Conrad Cunningham
Last modified: 19 December 1996.