Final Project

On Cloud9, create a folder named "final" in your cse201 workspace. Store all your work for your final project in that folder.

Your final project is to create a computer program that allows two people to play Connect 4.

Your program must be completed by 11:59 pm, Friday, December 9.

About Connect 4

In Connect 4, two players take turns dropping colored discs into a 6x7 grid. The first player to go has yellow discs, and the other player has red discs.

The discs are dropped from the top of the grid. The disc falls until it reaches the bottom or falls on top of another disc occupying the same column.

The winning condition is when 4 discs of the same color form a horizontal, vertical, or diagonal line. The game may result in a draw if the entire grid fills up without a winner.

Program specifications

Name your source file c4.cpp.

In your program, the turn player will enter the column number of where she wishes to drop her disc. Your program should display what the grid looks like each turn. Yellow discs should be labeled 'Y' and red discs should be labeled 'R'. An empty cell in the grid should be labeled ' '.

Your program should detect the winning conditions for horizontal and vertical wins. You will receive extra credit if your program can also detect diagonal wins.

Your program should halt when it detects that a player has won or there's a draw.

Connect4Grid class

I have created a class named Connect4Grid which you are required to use in your source code. The class is seperated into two files: Connect4Grid.h and Connect4Grid.cpp.

Place these files in the same folder as your c4.cpp.

To use the Connect4Grid class have

#include "Connect4Grid.h"
in c4.cpp. When compiling, use the command:
compile c4 c4.cpp Connect4Grid.cpp

Download Connect4Grid.h
Download Connect4Grid.cpp

Take a look at Connect4Grid.h to see documentation for it's member functions.

Here is an example of a program that uses Connect4Grid class:

#include "Connect4Grid.h"
#include <iostream>
using namespace std;

int main()
	Connect4Grid grid;
	int column;

	while (true) {
		cout << "Enter column index: ";
		if (not (cin >> column)) break;
		grid.drop(column, 'X');