Question: CPS 2 7 1 Machine Problem 7 - Recursion Objectives: implement a class and composition. To use the dynamic allocation to store objects and their

CPS 271 Machine Problem 7- Recursion
Objectives: implement a class and composition.
To use the dynamic allocation to store objects and their data.To use default constructor and overload constructor with full parameters.
To use setter functions and getter functions.To use Recursion
(Game: Connect four)
Connect four is a two-player board game in which the players alternately drop colored discs into a seven-column, six-row vertically suspended grid, as show below.
The objective of the game is to connect four same-colored discs in a row, a column, or a diagonal before your opponent can do likewise.
The program will have a ask the user for the column numbers from 0 to 6 for the two players to drop a red "R" or a yellow "Y" disc alternately. Whenever a disc is dropped, the program redisplays the board on the console and determines the status of the game (win, draw, or continue).
Here is a sample run:
0123456
Drop a red disc at column (06) : 0
0123456
R
Drop a yellow disc at column (06) : 3
0123456
RRY
Drop a red disc at column (06) : 0
0123456
...
Drop a yellow disc at column (06) : 6
0123456
RRYY
Drop a red disc at column (06) : 0
0123456
RRYRYRYYY
The red player won. Congratulations.
Create a program that allows the user to create vector of 6 x 7 of type character. Then the program will display the board, and prompt the first player for the column number. Assuming the column number is always valid (0-6), the program will have a method to check if there is a winner. You may need to write four functions, one to check the rows, one to check the columns, one to check the left diagonal and one to check the right diagonal.
The program will display the result only if there is a winner or the game ends in a draw.
Please submit your code and your output. No need to print all the screen shots of the game, you can just print the first few tries and the last one just like the example above.
I am going to assign a group of 2 or 3 students to work on this homework. The code must be done using C++, and you must use a recursion function to the search and the printing.
Copying any code from the internet will be considered cheating.
The due date must be met, no exceptions, no resubmission. You will show me your program if requested.
Extra credit: I will give extra credit if you play against the computer. Let the computer pick a random column.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!