-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile.hpp
69 lines (65 loc) · 1.11 KB
/
Tile.hpp
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
#pragma once
#include <stdexcept>
#include <iostream>
class Tile
{
int value; // Value of tile. Represent number of mines around
// or -1, if that tile is a mine.
int status; // Status of tile. Represent if a tile is hidden, marked or revealed
int additional; // Addtional status of tile. Represent if marked is correct or wrong
// (obviously if tile is marked)
public:
Tile()
{
value = 0;
status = 0;
additional = 0;
}
enum Value
{
BORDER = -2,
MINE = -1
};
enum Status
{
HIDDEN = 1,
REVEALED,
MARKED
};
enum MarkStatus
{
NOTHING,
WRONG_MARK,
CORRECT_MARK
};
void setValue(int value)
{
if (value < -2 || value > 8)
throw std::invalid_argument("Value must be from range [-2; 8]");
this->value = value;
}
void setStatus(Status status)
{
this->status = status;
}
void setMarkStatus(MarkStatus status)
{
additional = status;
}
Status getStatus() const
{
return static_cast<Status>(status);
}
MarkStatus getMarkStatus() const
{
return static_cast<MarkStatus>(additional);
}
int getValue()
{
return value;
}
operator int()
{
return value;
}
};