-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathboard.h
70 lines (46 loc) · 1.34 KB
/
board.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef BOARD_H
#define BOARD_H
#include <vector>
//#include "util.h"
#include "printer.h"
#include "player.h"
class Cell{
public:
Cell(int row, int col)
:column_coordinate(col), row_coordinate(row), occupied(false), playerOwned(NULL){
}
~Cell(){}
bool occupy (Player* p);
void free ();
Player* changePossession(Player* newPlayer);
bool isOccupied ()const;
bool belongsTo (const Player* p)const;
int getRow ()const;
int getColumn ()const;
Player* getPlayerOwned ()const;
private:
int row_coordinate;
int column_coordinate;
bool occupied;
Player* playerOwned;
};
class Board{
friend class Printer;
public:
Board(int size);
~Board();
bool playAt (const int row, const int col, Player* p);
Player* removeStone (const int row, const int col);
int countStonesFor(const Player* p);
bool isCellOccupied (const int row, const int col);
bool isCellOwnedBy (const int row, const int col, const Player* p);
bool isEmpty ()const;
bool isFull ()const;
int getSize ()const;
private:
int size;
std::vector< std::vector<Cell> > table;
int occupiedCells;
Cell& getCell(const int row,const int col);
};
#endif // BOARD_H