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 Machine Problem 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 twoplayer board game in which the players alternately drop colored discs into a sevencolumn, sixrow vertically suspended grid, as show below.
The objective of the game is to connect four samecolored 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 to 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:
Drop a red disc at column :
R
Drop a yellow disc at column :
RRY
Drop a red disc at column :
Drop a yellow disc at column :
RRYY
Drop a red disc at column :
RRYRYRYYY
The red player won. Congratulations.
Create a program that allows the user to create vector of x 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 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 or 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
