Java Reference
In-Depth Information
Write a test program that prompts the user to enter the number of rows and col-
umns of a two-dimensional array and then the values in the array and displays
true if the array contains four consecutive numbers with the same value. Other-
wise, display false. Here are some examples of the true cases:
0 1 0 3 1 6
1
0 1 0 3 1 6
1
0 1 0 3 1 6
1
0 1 0 3 1 6
1
0 1 6 8 6 0
1
0 1 6 8 6 0
1
0 1 6 8 6 0
1
0 1 6 8 6 0
1
5 6 2 1 8 2
9
5 5 2 1 8 2
9
5 6 2 1 6 2
9
9 6 2 1 8 2
9
6 5 6 1 1 9
1
6 5 6 1 1 9
1
6 5 6 6 1 9
1
6 9 6 1 1 9
1
1 3 6 1 4 0
7
1 5 6 1 4 0
7
1 3 6 1 4 0
7
1 3 9 1 4 0
7
3 3 3 3 4 0
7
3 5 3 3 4 0
7
3 6 3 3 4 0
7
3 3 3 9 4 0
7
***8.20
( Game: connect four ) Connect four is a two-player board game in which the
players alternately drop colored disks into a seven-column, six-row vertically
suspended grid, as shown below.
The objective of the game is to connect four same-colored disks in a row, a col-
umn, or a diagonal before your opponent can do likewise. The program prompts
two players to drop a red or yellow disk alternately. In the preceding figure, the
red disk is shown in a dark color and the yellow in a light color. Whenever a disk
is dropped, the program redisplays the board on the console and determines the
status of the game (win, draw, or continue). Here is a sample run:
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
———————————————
Drop a red disk at column (0-6): 0
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
|R| | | | | | |
———————————————
 
 
Search WWH ::




Custom Search