Подключить четыре игры [закрыто]C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Подключить четыре игры [закрыто]

Сообщение Anonymous »

Я пытаюсь закончить программу для игры Connect Four. Единственными двумя оставшимися методами являются «Uphill Win ()» и «Hower The Win ()». Метод «Uphill win ()» направлен на определение того, основан ли диагональ в гору 4-дюймовый й-кадре на «задержках» движении и игроке (x или 0).
Метод 'Downhillwin ()' Целью определить, есть ли диагональ спуска 4-дюйма.
Не могли бы вы помочь мне с этими двумя методами? < /p>
Код: < /p>
#include
#include

using namespace std;

const int ROWS = 6;
const int COLS = 7;

class ConnectFour {
private:
char cells[ROWS][COLS]; //a ROWS x COLS board of one of three characters ('X', 'O', ' '). Initialize all ' '
int movesLeft[COLS]; //an array containing the number of spaces left (or available) in each column. Initialize all 6
int lastPlayed; //records the last column that was played 0, 1, 2, 3, 4, 5, 6. Initialize -1
bool tiedGame; //records true if the board is full and no winner is found, otherwise false. Initialize false

bool horizontalWin(); //returns true if there is at least a horizontal 4-in-a-row. Hint: use cells and lastPlayed
bool verticalWin(); //returns true if there is at least a vertical 4-in-a-row. Hint: use cells and lastPlayed
bool uphillWin(); //returns true if there is at least a diagonal uphill 4-in-a-row. Hint: use cells and lastPlayed
bool downhillWin(); //returns true if there is at least a diagonal downhill 4-in-a-row. Hint: use cells and lastPlayed

public:
ConnectFour(); //initializes the attributes of the game;
void drawBoard(); //prints the gameboard with updated moves;
bool gameOver(); //return true if there is a four in row or a fullboard, if there is a full board, set tiedGame to true
bool isTiedGame(); //returns tiedGame
bool validMove(int j); //input: an attempt to play on column j; output: returns true if that play is valid
void play(int j, char c); //input: a valid play of c ('X' or 'O') in column j. update cells, lastPlayed, and movesLeft
};

//initializes the attributes of the game; prints boardgame
ConnectFour::ConnectFour() {

lastPlayed = -1;
tiedGame = false;

for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
cells[j] = ' ';
}
}
for (int j = 0; j < COLS; j++) {
movesLeft[j] = ROWS; //
}
}

//prints the gameboard with updated moves;
void ConnectFour::drawBoard() {
cout

Подробнее здесь: https://stackoverflow.com/questions/794 ... -four-game
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»