Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ only connect4.cpp: #include connect4.h Connect4::Connect4() { ClearBoard(); } Connect4::~Connect4() { // Intentionally empty } void Connect4::ClearBoard() { // Initialize Connect4 board for (int c

C++ only image text in transcribed
connect4.cpp:
#include "connect4.h" Connect4::Connect4() { ClearBoard(); } Connect4::~Connect4() { // Intentionally empty } void Connect4::ClearBoard() { // Initialize Connect4 board for (int c = 0; c = COLS) || (count[col] >= ROWS)) return false; // Make move int row = count[col]; board[row][col] = player; count[col]++; return true; } bool Connect4::CheckWin(char player) { // Loop over all starting positions for (int c = 0; c = 0) && (c+d = 0; r--) { // Draw dashed line cout
The primary goal of this programming assignment is to give students experience using pre-existing classes. You will be given a Connect4 class (connect4.h and connect4.cpp) that represents the classic 6x7 Connect4 board using a 2D array of characters. The Connect4 class also provides methods to clear the board, let a player make a move, display the board, and finally check to see if one player has won the game. The Connect4 class definition from connect4.h is given below: Global constants const int WIN-4; const int ROWS6; const int COLS = 7; / Class definition class Connect4 public: // Constructor and destructor Connect4) -Connect4) // Public methods void ClearBoard) bool MakeMove(int col, char player); bool CheckWin (char player); void PrintBoard); private: Private variables char board[ ROWS ] [ COLS]; int count [ COLS Your task is to write an interactive program that will allow the user to play the Connect4 game against the computer. To do this, you must implement a "game loop that lets the user and the computer take alternate turns placing their pieces on the board until one player or the other wins the game (or there are no spaces left to play in). To keep things simple, your computer player (the game Al) should choose a column to play in at random. Your program should display the board after every move, so the player can plan their strategy for winning the game. You should be able to implement this interactive game without making any changes to the Connect4 class

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_2

Step: 3

blur-text-image_3

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago