Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that plays the game of connect four. To see how to play the

ID: 3778674 • Letter: W

Question

Write a C++ program that plays the game of connect four. To see how to play the traditional 2-person game, visit page 2 of these instructions: http://www.hasbro.com/common/documents/dad2614d1c4311ddbd0b0800200c9a66/1EF 6874419B9F36910222EB9858E8CB8.pdf

Connect Four has a 6 x 7 board, and the goal of the game is to connect four pieces together horizontally, diagonally, or vertically. Your program will be a little different in that you can have a board of any size, rather than a 6x7 board, but you will always connect 4 pieces in this game. You need to make sure you handle inappropriate data, i.e. nonpositive integers, and ask the user again for the correct input. You must continue to play the game, until the user no longer wants to play.

2-player Example: ./connect_four –r 6 –c 7 Player one, do you want red or yellow (r or y)? r | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ Player 1, what column do you want to put your piece? 4 | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | r | | | | ------------------------ Player 2, what column do you want to put your piece? 5 | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | r | y | | | ------------------------ Player 1, what column do you want to put your piece? 4 | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | | | | | ------------------------ | | | | r | | | | ------------------------ | | | | r | y | | | ------------------------ Player 2, what column do you want to put your piece?... … Do you want to play again (1-yes, 2-no): 1 How many rows, cols? 10 10

A requirement for this program is that your functions are 15 lines or less, and you must not have any global variables. In addition, the command-line argument option and value pair can come in any order, and if one of the options or values are not valid, then you need to print a message an exit. Also, you cannot have any memory leaks in your program!!!

(10 pts) Extra Credit: Connect Any In this game, you will get the number of pieces you want to connect in a row, which can be 2-any number. This determines how many pieces have to be in a row horizontally, vertically, or diagonally to win! This will be an extra command line argument with a –p option before the value. ./connect_four –r 6 –c 7 –p 4

Explanation / Answer

#include using namespace std; void display(); bool check(int a, int b); int drop(int b, char player); char place[6][7];//available for whole program int main(){     for(int a =0;a
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote