-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicTacToeGame.h
More file actions
60 lines (44 loc) · 1.04 KB
/
TicTacToeGame.h
File metadata and controls
60 lines (44 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef _TICTACTOE_GAME_
#define _TICTACTOE_GAME_
#include <exception>
#include <utility>
#include "TicTacToeBoard.h"
class TicTacToeGame {
public:
typedef enum _Winner {
Xs, Os, CAT
} Winner;
private:
TicTacToeBoard board;
uint32_t turn;
typedef enum _GameState {
ST_X_TURN,
ST_O_TURN,
ST_GAME_OVER
} GameState;
GameState currentState;
void advanceGameState(int row, int col);
void advanceToNextTurn();
bool intersectsWinningMarkerSet(int row, int col);
bool intersectsWinningRow(int row);
bool intersectsWinningColumn(int col);
bool intersectsWinningDiagonal(int row, int col);
bool checkForCatsGame();
bool isSquareEmpty(int row, int col);
bool allEqual(MarkerSet & m);
void setWinner();
Winner winner;
public:
TicTacToeGame();
bool isGameOver();
Marker getCurrentMarker();
Winner getWinner();
void TakeTurn(int row, int col);
};
class GameInProgressException : std::exception {
public:
char* what() {
return "Game Currently in Progress, No Result Yet";
}
};
#endif