-
Notifications
You must be signed in to change notification settings - Fork 0
/
Piece.h
101 lines (81 loc) · 1.97 KB
/
Piece.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// jammon17@georgefox.edu
// Assignment 9
// 2019-04-24
#ifndef _PIECE_H
#define _PIECE_H
#include <string>
using namespace std;
// forward declarations
class Square;
class Player;
/**
* Implements a Piece object with a location and color
*/
class Piece {
public:
/**
* Piece Constructor
*
* @param location - (Square*)
* @param color - (string&)
*/
Piece(Square* location, string& color);
/**
* Gets the color attribute
* Returns "W" for white and "B" for black
*
* @return color (string)
*/
string getColor();
/**
* Gets the Piece's board location
* Returns a pointer to the square object the piece is on the
* board, if it isn't on the board it will return null
*
* @return rank (int)
*/
Square* getLocation();
/**
* Sets the location attribute to a pointer to a Square object
*
* @param location (Square*)
*/
void setLocation(Square* location);
/**
* Checks if the piece object is on the board
*
* @return true if on the board else false
*/
bool isOnSquare();
/**
* Checks if the piece object can move to the given Square
*
* @param location (Square&)
* @return true if the move is valid else false
*/
virtual bool canMoveTo(Square& location);
/**
* Moves the piece object to the given Square
*
* @param location (Square&)
* @param byPlayer (Player&)
* @return true if the move is valid else false
*/
virtual bool moveTo(Square& location, Player& byPlayer);
/**
* Checks if the player's move put the opponent in check
*
* @param byPlayer (Player&)
* @return true if the move opponent is in check
*/
bool checkForCheck(Player& byPlayer);
/**
* Displays the piece color and type
*/
virtual void display() = 0;
private:
// private attributes
Square* _location;
string _color;
};
#endif //_PIECE_H