Question
Write a code that plays the game of connect four in java. It needs to contain two classes( one class holds the connect four board).
Write a code that plays the game of connect four in java. It needs to contain two classes( one class holds the connect four board). It also must contain a play again feature and comments on the code
Explanation of the game: 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. 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 |
Step by Step Solution
3.37 Rating (156 Votes )
There are 3 Steps involved in it
Step: 1
Heres a simple implementation of Connect Four in Java with two classes one for the game board ConnectFourBoard and another for the game logic ConnectF...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started