Classwork/Homework:
(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 column, 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| | | | | | | ——————————————— Drop a yellow disk at column (0–6): 4 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |R| | | |Y| | | . . . . Drop a yellow disk at column (0–6): 6 | | | | | | | | | | | | | | | | | | | | |Y| | | | | | |Y|Y|Y|R| | | |Y|R|R|Y|Y| |R|Y|R|Y|R|R|R| ——————————————— The yellow player won Do you want to play again?
Write the two-player program, YI_Connect4.java. Display at a every move the board as shown in the example above. Include a prompt to continue playing.
Your program should include:
1. Good documentation
2. An introduction message
3. Functions (Optional)
4. An end of game message
5. Input/output
What is good documentation?
Answer:
- Header with author’s name, assignment description, date and python version.
- Comments in each function. A short sentence will be sufficient.
- Comments for code snippets written for specific handling. An example might be checking if there are 3 in a row, or 4 in a row.
- Comments to indicate unusual or rare situations that don’t follow a pattern or repetition.