-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
47 lines (31 loc) · 870 Bytes
/
Game.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
39
40
41
42
43
44
45
46
47
#ifndef GAME_H
#define GAME_H
/*
* Class to model the game. Holds sets of human moves, computer
* moves and free spaces.
*
*/
#include <stdexcept>
#include <set>
#include "Player.h"
using namespace std;
typedef set<int> IntSet;
class Game
{
public:
Game(Player* human_p, Player* computer_p);
~Game();
void reset(Player* human_p, Player* computer_p) throw();
void addMove(int move, Player* player_p) throw (invalid_argument);
// Returns whether any move is available
bool moveAvailable() const;
// Returns whether the given move is available
bool moveAvailable(int) const;
// Returns a copy of the set of available moves
const IntSet& getAvailable() const;
private:
IntSet availableMoves_m;
// Throws an exception if the move is not available
void checkAvailableMoves(int move) throw (invalid_argument);
};
#endif // GAME_H