Class 6 - Assignment

Deitel & Deitel, ch. 9; ch. 10 (sect. 1-8)

Deitel & Deitel: Problem 9.24, 10.24, 12.21, 13.19/13.21

The first two problems should be done as applets. The latter two problems may be done either as applications or applets (your choice).

Assigned Dec 7, 1998; due Dec 14, 1998, at midnight.

Problem 9.24
Write an applet that simulates a screen saver. The applet should randomly draw lines. After drawing 100 lines, the applet should clear itself and start drawing lines again.
Problem 10.24
Write a program that plays "guess the number" as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1-1000. The program then displays in a label:
I have a number between 1 and 1000. Can you guess my number?
Please enter your first guess.
A TextField 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 uneditable TextField should display either "Too High" or "Too Low" to help the user zero in on the correct answer. When the user gets the correct answer "Correct!" should be displayed and the TextField used for input should be changed to uneditable.

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 input TextField changed to editable.

Problem 12.21
Use inheritance to create an exception superclass and various exception subclasses. Write a program to demonstrate that the catch specifying the superclass catches subclass exceptions.
Problem 13.19/13.21
Write a Java program to demonstrate that as a high-priority thread executes, it will delay the execution of all lower-priority threads. Also demonstrate the high-priority thread using sleep to give lower-priority threads a chance to run.