-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtictactoe.h
38 lines (30 loc) · 1.07 KB
/
tictactoe.h
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
// Declares classes for a Tic-tac-toe program to be used in a CPS 222
// lab on Git and GitHub.
//
// Author (starting point): Russ Tuck
// Authors (everything else):
// Instructor's note: the #ifndef/define/endif TICTACTOE_H_ statements are
// a "header guard". Together, they make it safe to #include this file
// anywhere it's needed: extra #includes will be ignored.
#ifndef TICTACTOE_H_
#define TICTACTOE_H_
#include <iostream>
using std::istream;
enum class TictactoeXO {X, O, none};
// Stores and manipulates the board and state of a Tic-tac-toe game.
// Example:
//
class TictactoeBoard {
public:
TictactoeXO get(unsigned row, unsigned col);
void set(unsigned row, unsigned col, TictactoeXO player);
// Checks for a winner and returns result (none if no winner).
TictactoeXO winner();
private:
TictactoeXO board_[3][3] = {
{ TictactoeXO::none, TictactoeXO::none, TictactoeXO::none},
{ TictactoeXO::none, TictactoeXO::none, TictactoeXO::none},
{ TictactoeXO::none, TictactoeXO::none, TictactoeXO::none}
};
};
#endif // TICTACTOE_H_