-
Notifications
You must be signed in to change notification settings - Fork 1
/
field.cpp
45 lines (39 loc) · 807 Bytes
/
field.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
#include "field.h"
Field::Field()
{
for (int i = 0; i < Size; i++)
for (int j = 0; j < Size; j++)
f[i][j] = '\0';
}
Field::Field(Field &from)
{
for (int i = 0; i < Size; i++)
for (int j = 0; j < Size; j++)
f[i][j] = from.f[i][j];
}
Field::~Field() {}
char Field::getCell(int x, int y)
{
if (x < 0 || x >= Size || y < 0 || y >= Size)
return '!';
return f[x][y];
}
void Field::setCell(int x, int y, char c)
{
if (x < 0 || x >= Size || y < 0 || y >= Size)
return;
if (f[x][y] != '\0')
return;
f[x][y] = c;
}
void Field::debugOutput()
{
for (int i = 0; i < Size; i++)
{
QString nobodyReadsIt = "";
for (int j = 0; j < Size; j++)
nobodyReadsIt += f[i][j];
qDebug() << nobodyReadsIt;
qDebug() << '\n';
}
}