Website Summary Files Commits Branches @commit @diff @stats
path: root / DiamondProblemAndPolymorphism / Chess / Rook.hpp
blob: d973870764e044ad412282bac400430366efbe35 (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
#pragma once
#include "Figure.hpp"

class Rook : virtual public Figure
{

public:
	Rook(int xCoordinate, int yCoordinate, bool isWhite) :Figure(xCoordinate, yCoordinate, isWhite)
	{}
	
	bool Move(int xNew, int yNew);
	
	void Print();
	
};

bool Rook::Move(int xNew, int yNew)
{
	if (!isValidCoord(xNew, yNew))
		return false;
	if (!(xCoord == xNew ^ yCoord == yNew))
		return false;
	xCoord = xNew;
	yCoord = yNew;
	return true;
}

void Rook::Print()
{
	cout << 'R';
}