Programming and Problem Solving with Java

(やまだぃちぅ) #1
631

Each player’s position should be input as indexes into the Tic-Tac-Toe
board—that is, a row number, a space, and a column number. Make the applica-
tion user-friendly.
After each game, print out a diagram of the board showing the ending posi-
tions. Keep a count of the number of games each player has won and the num-
ber of draws. Before the beginning of each game, ask each player if he or she
wishes to continue. If either player wishes to quit, print out the statistics and
stop. Use buttons as appropriate.

2.Photos taken in space by the Galileo spacecraft are sent back to earth as a
stream of numbers. Each number represents a level of brightness. A large num-
ber represents a high brightness level, and a small number represents a low
level. Your job is to take a matrix (a two-dimensional array) of these numbers
and print it as a picture.
One approach to generating a picture is to print a dark character (such as a
$) when the brightness level is low, and to print a light character (such as a
blank or a period) when the level is high. Unfortunately, errors in transmission
sometimes occur. Your photo-generation code should first attempt to find and
correct these errors. Assume a value is in error if it differs by more than 1 from
each of its four neighboring values. Correct the erroneous value by giving it the
average of its neighboring values, rounded to the nearest integer.
Example:
5 The 2 would be regarded as an error and
4 2 5 would be given a corrected value of 5.
5
Note that you must process values on the corners or boundaries of the matrix
differently than the values on the interior. Your application should print an im-
age of the uncorrected picture and then an image of the corrected picture.


3.The following diagram represents an island surrounded by water (shaded area).


Starting position
of mouse

Bridge

Bridge

Water

A mouse in this position
has not yet escaped.
Free download pdf