-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.cpp
72 lines (57 loc) · 1.34 KB
/
Log.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "Log.h"
Log::Log() {
pieceName = "none";
startPos = "none";
startRow = -1, startCol = -1;
endPos = "none";
endRow = -1, endCol = -1;
}
Log::Log(string name, int startRow, int startCol, int endRow, int endCol) {
pieceName = name;
this->startRow = startRow;
this->startCol = startCol;
this->endRow = endRow;
this->endCol = endCol;
string rowConvTable[] = {"8", "7", "6", "5", "4", "3", "2", "1"};
string colConvTable[] = {"a", "b", "c", "d", "e", "f", "g", "h"};
string temp = "";
temp += colConvTable[startCol];
temp += rowConvTable[startRow];
startPos = temp;
temp = "";
temp += colConvTable[endCol];
temp += rowConvTable[endRow];
endPos = temp;
logMessage = pieceName + " moved from " + startPos + " to " + endPos;
}
string Log::GetPieceName() {
return pieceName;
}
string Log::GetStartCoord() {
return startPos;
}
int Log::GetStartCoordRow() {
return startRow;
}
int Log::GetStartCoordCol() {
return startCol;
}
string Log::GetEndCoord() {
return endPos;
}
int Log::GetEndCoordRow() {
return endRow;
}
int Log::GetEndCoordCol() {
return endCol;
}
void Log::PrintLog() {
cout << logMessage << endl;
}
bool Log::operator==(const Log& rhs) const {
return this->pieceName == rhs.pieceName &&
this->startRow == rhs.startRow &&
this->startCol == rhs.startCol &&
this->endRow == rhs.endRow &&
this->endCol == rhs.endCol;
}