Connect Four is a two-player game in which the players take turns dropping their colored discs from the top into a seven
Posted: Thu May 05, 2022 1:01 pm
Connect Four is a two-player game in which the players take
turns dropping their colored discs
from the top into a seven-column, six-row vertically-suspended
grid. The pieces fall straight down,
occupying the next available space within the column. The object of
the game is to connect four
of one’s own discs of the same color next to each other vertically,
horizontally, or diagonally before
one’s opponent can do so. In the image below, red would have won
this game since there are four
red discs in a column.
Java
This project is to make a program for playing this game. The
first player should be red and the
second yellow. Have the program alternate between the two
players having the users select a column
to drop their disc. The program should test for a win at each
move and if a particular player wins,
it should stop the game and announce the winner. The program
should then ask the user if they
would like to play another game and if so, start a new game.
When they decide to end, the program
should neatly print out a final score of the total number of
games, as well as each player’s number
of wins. The game-board display should be a simple display of
R’s and Y’s, such as,
Y | R | R Ꭱ ] Ꭱ ] | Y | R | Y | R | Y | R | Y Y | Y | Y R | Y | | Y | R | Y | R 1 | 2 | 3 | 4 | 5 | 6 | 7
turns dropping their colored discs
from the top into a seven-column, six-row vertically-suspended
grid. The pieces fall straight down,
occupying the next available space within the column. The object of
the game is to connect four
of one’s own discs of the same color next to each other vertically,
horizontally, or diagonally before
one’s opponent can do so. In the image below, red would have won
this game since there are four
red discs in a column.
Java
This project is to make a program for playing this game. The
first player should be red and the
second yellow. Have the program alternate between the two
players having the users select a column
to drop their disc. The program should test for a win at each
move and if a particular player wins,
it should stop the game and announce the winner. The program
should then ask the user if they
would like to play another game and if so, start a new game.
When they decide to end, the program
should neatly print out a final score of the total number of
games, as well as each player’s number
of wins. The game-board display should be a simple display of
R’s and Y’s, such as,
Y | R | R Ꭱ ] Ꭱ ] | Y | R | Y | R | Y | R | Y Y | Y | Y R | Y | | Y | R | Y | R 1 | 2 | 3 | 4 | 5 | 6 | 7