Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please just in C++. Nothing else. not regular C or anything else only C++. A Friendly Game of Connect Four The name of this project

Please just in C++. Nothing else. not regular C or anything else only C++.

A Friendly Game of Connect Four

The name of this project says it all. You are going to be creating a Connect Four game. For those of you that are not familiar with Connect Four you can actually find a lot of information on Wikipedia about it, however these are the things that you need to know for certain for our game of connect four.

1. You will be working with a Connect Four board that is of size 7 x 6 (that is 7 columns by 6 rows).

2. The two player colors should be represented on your board with an R for red and a Y for yellow.

The first player begins by dropping one of his/her discs into the center column of the game board. The two players then alternate turns dropping one of their discs at a time into an unfilled column until one player achieves four in a row -- either horizontally, vertically or diagonally; the player that does so wins the game. However, if the game board fills up before either player achieves four in a row, then the game is a draw.

Note: You do not get to select where the disc goes on the board as in tic-tac-toe, when you select a column, the disc will fall to the first row that has an open slot (again, look up game play if needed online).

Since we are playing this game on the computer and don't have the physical board in front of us, you should represent "open slots" with an asterisk (*). The entire board should be "open" at the beginning of game play.

To make things a little easier, we will also say that the player playing the RED discs will go first every time.

Start off by displaying the contents of the board.

As noted in the instructions, the first player must drop their disc into the center column of the game board and from there they start taking turns. When turns begin the program should ask the user to enter the row and column number. You must ask the first player this question, it should not be automatic. Therefore, remember that you will need to validate that he/she has played their disc in the right location of the board.

Your program should have a minimum of five functions in addition to the your main function.

1. A function that will display the contents of the game board.

2. A function that will allow a player (R or Y) to take a turn.

3. A function that will determine if the game is over. There are four ways for the game to end: (a) a connect four occurs either (1)horizontally, (2) vertically, (3) diagonally, or (b) the game board is filled and there is no connect four, therefore a result in a draw.

4. A function that will accept the game board and a player symbol (R or Y) as arguments, and will return true if the player has won.

5. A function that will display the winner of the game

Every time one of the player makes a move you need to be sure that you display how the game board appears at that point in time.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Is this investment worthwhile? Why or why not?

Answered: 1 week ago