-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.cpp
More file actions
44 lines (28 loc) · 935 Bytes
/
Square.cpp
File metadata and controls
44 lines (28 loc) · 935 Bytes
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
#include "Square.h"
/* default constructor provides an empty square, represented by
* an empty piece - EMP and illegal color 2. "transparent piece"/
* Default c'tor is needed, because Board class has an array of squares, initialized by default constructor.
* No need for copy constructor or destructor, because data members are primitive values.
*/
Square::Square() : owner(EM), id(-1) {
}
// Index of square
int const &Square::getId() const {
return id;
}
//Piece, placed on square
Piece const &Square::getOwner() const {
return owner;
}
void Square::setOwner(Piece &new_owner) {
this->owner.setName(new_owner.getName());
this->owner.set_counter(new_owner.get_counter());
}
bool Square::isOccupied() const {
if (owner.getName() == EM || owner.getName() == IV)
return false;
return true;
}
bool Square::operator==(const Square &rhs) const {
return getOwner() == rhs.getOwner();
}