forked from mahdisn76/UIAI2017_cpp_client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.cpp
55 lines (46 loc) · 822 Bytes
/
cell.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "cell.h"
void Cell::set_checker(int x, int y, char c)
{
if(c=='e')
checker = nullptr;
checker = new Checker(x,y,c);
}
Cell::Cell(int x,int y, char c)
{
pos = new Pos(x,y);
if(c=='e')
checker = nullptr;
else
checker = new Checker(x,y,c);
}
Cell::Cell()
{
pos = new Pos(0,0);
checker=nullptr;
}
Cell::~Cell()
{
if(pos!=nullptr)
delete pos;
if(checker!=nullptr)
delete checker;
pos = nullptr;
checker=nullptr;
}
int Cell::return_num()
{
if(get_checker() == nullptr)
return 0;
else if(get_checker()->isMyChecker() == true)
return 1;
else if (get_checker()->isMyChecker() == false)
return 2;
}
Checker* Cell::get_checker()
{
return checker;
}
Pos& Cell::get_pos()
{
return *pos;
}