-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchessBoard.cpp
More file actions
69 lines (58 loc) · 1.75 KB
/
Copy pathchessBoard.cpp
File metadata and controls
69 lines (58 loc) · 1.75 KB
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
#include <iostream>
#include "chessBoard.h"
using namespace std;
ChessBoard::ChessBoard() {
//init
for(int i = 0; i < CHESSBOARD_SIZE; i++)
for(int j = 0; j < CHESSBOARD_SIZE; j++)
chessBoard[i][j] = '_';
//White
chessBoard[0][0] = 'R';
chessBoard[0][1] = 'N';
chessBoard[0][2] = 'B';
chessBoard[0][3] = 'Q';
chessBoard[0][4] = 'K';
chessBoard[0][5] = 'B';
chessBoard[0][6] = 'N';
chessBoard[0][7] = 'R';
chessBoard[1][0] = 'P';
chessBoard[1][1] = 'P';
chessBoard[1][2] = 'P';
chessBoard[1][3] = 'P';
chessBoard[1][4] = 'P';
chessBoard[1][5] = 'P';
chessBoard[1][6] = 'P';
chessBoard[1][7] = 'P';
//Black
chessBoard[7][0] = 'R';
chessBoard[7][1] = 'N';
chessBoard[7][2] = 'B';
chessBoard[7][3] = 'Q';
chessBoard[7][4] = 'K';
chessBoard[7][5] = 'B';
chessBoard[7][6] = 'N';
chessBoard[7][7] = 'R';
chessBoard[6][0] = 'P';
chessBoard[6][1] = 'P';
chessBoard[6][2] = 'P';
chessBoard[6][3] = 'P';
chessBoard[6][4] = 'P';
chessBoard[6][5] = 'P';
chessBoard[6][6] = 'P';
chessBoard[6][7] = 'P';
}
//getters
const char (&ChessBoard::getChessBoard() const) [CHESSBOARD_SIZE][CHESSBOARD_SIZE] {
return chessBoard;
}
//print
ostream& operator<<(ostream& os, const ChessBoard& c) {
const char (&board)[ChessBoard::CHESSBOARD_SIZE][ChessBoard::CHESSBOARD_SIZE] = c.getChessBoard();
for(int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
os << board[i][j] << " ";
}
os << "\n";
}
return os;
};