-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure.cpp
73 lines (62 loc) · 1.12 KB
/
Figure.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "Figure.h"
#include <iostream>
#include <cstring>
using namespace std;
Figure::Figure(char const *name, FigureColor color)
{
this->name = new char[strlen(name) + 1];
assert(this->name != NULL);
strcpy(this->name, name);
this->color = color;
unmoved = false;
}
Figure::Figure(const Figure &other)
{
copy(other);
}
Figure& Figure::operator=(const Figure &other)
{
if (this != &other)
{
erase();
copy(other);
}
return *this;
}
Figure::~Figure()
{
erase();
}
bool Figure::operator==(char const* str) const
{
return !strcmp(name,str);
}
void Figure::setColor(bool other)
{
this->color = other;
}
void Figure::setName(char const* name)
{
erase();
this->name = new char[strlen(name) + 1];
assert(this->name != NULL);
strcpy(this->name, name);
}
char * Figure::getName() const
{
return this->name;
}
FigureColor Figure::getColor() const
{
return this->color;
}
void Figure::print() const
{
if (!(*this=="Free"))
{
if (color.isWhite())
cout << "W " << name;
else
cout << "B " << name;
}
}