Comp242-hw3dsadfa - #include u using namespace...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> # using namespace std; u class TicTacToe { private: enum Status { P1WIN, P2WIN, DRAW, CONTINUE }; char board[3][3]; public: TicTacToe(); ~TicTacToe(){} void printBoard(); bool validMove(int r, int c); void xoMove(int r, int c, char value); Status gameStatus(int MoveCounter); }; } TicTacToe::TicTacToe() { for (int row=0; row<3; row++) { for (int col=0; col<3; col++) { board[row][col] = '-'; } } } void TicTacToe::printBoard() { cout << endl; cout << " 0 1 2\n"; for (int row=0; row<3; row++) { cout << row << " "; for (int col=0; col<3; col++) { cout << board[row][col] << " "; } cout << endl; } cout << endl; } bool TicTacToe::validMove(int r, int c) { return true; else return false; } void TicTacToe::xoMove(int r, int c, char value) { board[r][c] = value; } TicTacToe::Status TicTacToe::gameStatus(int MoveCounter)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ if (((board[0][0] == 'X') && (board[0][1] == 'X') && (board[0][2] == 'X')) || ((board[1][0] == 'X') && (board[1][1] == 'X') && (board[1][2] ==
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Comp242-hw3dsadfa - #include u using namespace...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online