-
Notifications
You must be signed in to change notification settings - Fork 0
/
Square.cpp
49 lines (43 loc) · 892 Bytes
/
Square.cpp
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
#include "StdAfx.h"
#include "Piece.h"
#include "Square.h"
CSquare::CSquare(bool containsPiece, CPiece* piece, short theRow, short theColumn)
: bContainsPiece(containsPiece),
pPiece(piece),
row(theRow),
column(theColumn)
{
if (bContainsPiece)
{
if (pPiece != NULL)
{
pPiece->setPosition(pPiece->getPositionFromRowAndColumn(row, column));
}
}
}
CSquare::~CSquare(void)
{
if (pPiece != NULL)
{
delete pPiece;
pPiece = NULL;
}
bContainsPiece = false;
}
CSquare::CSquare(const CSquare& s)
{
short thisRow = this->row;
short thisColumn = this->column;
*this = s;
row = thisRow;
column = thisColumn;
}
CSquare& CSquare::operator=(const CSquare& s)
{
short tempRow = this->getRow();
short tempColumn = this->getColumn();
pPiece = s.pPiece;
this->setRow(tempRow);
this->setColumn(tempColumn);
return *this;
}