-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.cpp
34 lines (30 loc) · 1.03 KB
/
player.cpp
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
/*------------------------------------------------------------------------------
Player class implementation
player.hpp
------------------------------------------------------------------------------*/
#include <iostream>
using namespace std;
#include "player.hpp"
ostream& operator<<(ostream& os, const Player& player)
{
// This commented implementation is not supported by g++ 4.7, who says:
// "sorry, unimplemented: non-trivial designated initializers not supported"
// static const char player2char[] = {
// [player_e::NONE] = '.',
// [player_e::O] = 'O',
// [player_e::X] = 'X'
// };
// os << player2char[static_cast<int>(player.get())];
if (player.get() == player_e::NONE) {
os << " ";
} else if (player.get() == player_e::X) {
os << "X";
} else if (player.get() == player_e::O) {
os << "O";
} else {
cerr << __func__ << ": error in player input variable: " << player.get()
<< endl;
exit(1);
}
return os;
}