Project 2 - Connect Four
Part 1 - Due - Friday, October 15, 2004
Part 2 - Due - Friday, October 22, 2004
Part 3 - Due - Monday, November 1, 2004
The goal of this project is to give you an opportunity to practice using object-oriented design and recursion. Your program should be implemented in C++ and should use classes where appropriate. Points will be deducted for poor design. You will implement two versions of this program, one iterative and one recursive.
In this project, you will write a program which allows two users (both human) to play a game of Connect Four. You can visit the following website for an example of how the game works: http://www.irt.org/games/js/connect/. The game is played using a board with 7 columns and 6 rows. Each player is assigned a color, one player is red and one player is black. At each turn, a player places a checker of her color in the top empty space of one of the columns. Once a checker has been placed, your program should check to see if a player has won the game, or if the board is full. A player wins if four checkers of her color are adjacent either vertically, horizontally, or diagonally. If there is a win or tie, the program should print an appropriate message and exit. If not, the next player takes a turn.
Your program will represent the board using text only. For example, your program might display:
| | | | | | | |
---------------
| | | | | | | |
---------------
| | | |R| | | |
---------------
| | | |B| | | |
---------------
| | |R|B| | | |
---------------
|B|R|B|B| | |R|
1 2 3 4 5 6 7
A user can specify where she would like to place her checker by simply specifying the column number.
Implementation Hints
Your program must adhere to the following guidelines unless we have explicitly discussed an alternative.
Your program must use classes where appropriate. You should have at least two classes in addition to a driver which contains your main function. When designing your classes, think about the objects which are used to play the game and the actions performed with or by each object.
If a user chooses to place a checker in a full column, an error message should be displayed and the user should be prompted for another selection.
You must implement TWO versions of the function(s) which determine whether or not a player has won. In version 1, implement an iterative algorithm to perform the check. In version 2, implement a recursive algorithm which checks for a winner. Make sure you only test one implementation at a time. However, you will be asked to demonstrate both and submit both versions of your program.
Part 1 - Due Friday, October 15, 2004
For part 1, you must submit the design of your program and
algorithms for each piece of your design. This should include a
short description of each class you plan to implement, the members
(variables and functions) of each class, and complete algorithims
for each member function (including main). For this portion,
submit an iterative algorithm for determining a winner.
Part 2 - Due Friday, October 22, 2004
For part 2, you must submit a refined design and algorithm for your
entire program along with a recursive algorithm for derminining a
winner. Note, your final implementation should have both an iterative
and a recursive of the check for winner function(s).
Part 3 - Due Monday, November 1, 2004
- Complete and submit your working code.
- Make sure that each function is well documented. Your documentation should specify the type and function of the input paramaters and ouput.
- Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
- Make sure I have seen your program run. Demonstrations to
be scheduled.
Reminder: No part of your code may be copied from any other
source. All code submitted must be original code written by you.
Sami Rollins