Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 15 / Chess / ChessBoard / ChessBoard.cpp
blob: dc809cc81e637e91e9beeb4f0b68f114080b6b5b (plain) (blame)
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
#include "ChessBoard.h"
#include "../FigureFactory/FigureFactory.h"

ChessBoard::ChessBoard()
{
	FigureFactory factory;
	for (int i = 0; i < BOARD_SIZE; i++)
	{
		board[1][i].f = factory.createPawn(false);
		board[6][i].f = factory.createPawn(true);
	}

	board[0][0].f = factory.createRook(false);
	board[0][7].f = factory.createRook(false);

	board[7][0].f = factory.createRook(true);
	board[7][7].f = factory.createRook(true);

	
	board[0][1].f = factory.createKnight(false);
	board[0][6].f = factory.createKnight(false);
	board[7][1].f = factory.createKnight(true);
	board[7][6].f = factory.createKnight(true);

	board[0][2].f = factory.createBishop(false);
	board[0][5].f = factory.createBishop(false);
	board[7][2].f = factory.createBishop(true);
	board[7][5].f = factory.createBishop(true);

	board[0][3].f = factory.createKnig(false);
	board[0][4].f = factory.createQueen(false);
	board[7][4].f = factory.createQueen(true);
	board[7][3].f = factory.createKnig(true);
}

void ChessBoard::print() const
{
	for (int i = 0; i < BOARD_SIZE; i++)
	{
		for (int j = 0; j < BOARD_SIZE; j++)
		{
			board[i][j].print();
		}
		std::cout << std::endl;
	}
}