Programming Assignment 4
Comp 170
Due: Thursday, March 24
Topic: 2-D arrays and functions
Game: Connect 4
2 players take turns placing letters in columns. (X’s & O’s)
Game Board has 7 Columns and 6 Rows
const int ROWS = 6;
const int COLUMNS = 7;
char GameBoard[ROWS][COLUMNS];
1 2 3 4 5 6 7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rules:
Initialize your game board to all spaces.
Your game should recognize a winning move and announce the winner.
You need to have a function to display the game board.
You must get the users move by allowing them to select a column.
Then place that player’s letter at the bottom of the specified column.
If the column is already full let the player move in a different column.
If the game board is full the game is over. Call it a tie.
Be sure to tell at each move whose turn it is.
The player who moves first is X the other player is O.
You may have global constants but not variables.