-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsquare.cc
71 lines (61 loc) · 1.28 KB
/
square.cc
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
// square.cc
#include<iostream>
#include<cassert>
#include<iomanip>
#include "colors.h"
#include "square.h"
#include "tile.h"
using namespace std;
Square::Square(int xcoord, int ycoord):
x(xcoord),
y(ycoord),
tile(nullptr),
multiplier(NONE)
{
}
Square::~Square() {}
void Square::show() const
{
if(tile)
cout << CYAN << setw(4) << tile->getLetter() << RESET << setw(4);
else
{
switch(multiplier)
{
case DOUBLE_LETTER:
cout << BLUE << setw(4) << y*15+x << RESET << setw(4); break;
case TRIPLE_LETTER:
cout << GREEN << setw(4) << y*15+x << RESET << setw(4);break;
case DOUBLE_WORD:
cout << RED << setw(4) << y*15+x << RESET << setw(4);break;
case TRIPLE_WORD:
cout << YELLOW << setw(4) << y*15+x << RESET << setw(4);break;
case NONE: cout << setw(4) << y*15+x << setw(4); break;
default: break;
}
}
}
void Square::setTile(Tile* t)
{
tile = t;
//CANNOT SELFTEST: TILE DOES NOT HAVE THIS SQUARE*
}
Tile* Square::showTile() const
{
return tile;
}
void Square::setPremium(premium p)
{
multiplier = p;
}
premium Square::getPremium() const
{
return multiplier;
}
void Square::selfTest() const
{
//cout << "Testing square ... ";
//cout << "My tile:" << tile << endl;
assert(tile == nullptr || this == tile->showSquare());
//out << "passed" << endl;
}