OOP - Assignment 1

Topic: Connect 4

Points: 25

Due: 1-20-2004 at class time

Instructor: Dana Steil

Turn In: Printed Copy of Source File Connect 4.cpp and Summit it on EASE

Objective:

The goal of this assignment is to get you, the student, back in the programming grove. If you feel that this assignment is too simple, just wait, I promise to challenge you in the future. If you feel that this assignment is too difficult please come to talk to me about your programming background. I want to make sure you are enrolled in the proper level programming course.

Connect 4 Rules:

The game is played on a 7 column by 6 row board. Two players play by alternately dropping a chip down one of the columns. The chip drops to the lowest unoccupied spot in that column. The first player to get four chips in a row, vertical, horizontal, or diagonal, wins. The game ends in a stalemate when the board is filled with chips and nether player has 4 chips in a row.

Application Type & Platform:

You are expected to write a C++ console application. I will be grading your project in Windows XP using the Microsoft .NET 7.0 IDE. Be sure to test your program in this environment before submitting it. If you do not have the same environment and or platform on your personal computer please be sure it works in the Alltel lab before submitting it.

Expected Interface:

 

Representing the Players and their Chips:

There are two players. The players should be named A and B. An A should be used to represent player As chips and a B should be used to represent player Bs chips. Player A should be allowed to play first then player B.

 

Displaying the Board:

Empty slots should be represented by a capital letter O.

 

When the board is empty it should be displayed as follows.

1234567

OOOOOOO

OOOOOOO

OOOOOOO

OOOOOOO

OOOOOOO

OOOOOOO

 


When the board has one chip added to each of the first two columns it should be displayed as follows.

 

1234567

OOOOOOO

OOOOOOO

OOOOOOO

OOOOOOO

OOOOOOO

ABOOOOO

 

Prompting the player for a move:

After displaying the game board, skip 1 line then prompt the player as follows.

 

Player As turn. Select a column.

Or

Player Bs turn. Select a column.

 

The player should then be required to enter a valid column and hit enter.

If the player selects a valid column that is not full:

The proper chip should be added to that row.

The board should be displayed.

The next player should be prompted for their move.

 

If the player selects an invalid column or one that is full:

The user should receive the error message as follows:

Invalid or full column

The user should then be prompted again for a move.

 

Other game functionality:

The game should detect when a player has won then display the message:

Congratulations, A wins!

Or

Congratulations, B wins!

 

The game should detect if a stalemate occurs then display the message:

Sorry, Stalemate.

 

The game should not ask the user to play again.

No other functionality should be added to the game.