-
Notifications
You must be signed in to change notification settings - Fork 2
/
textdisplay.cc
52 lines (48 loc) · 1.46 KB
/
textdisplay.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
#include <utility>
#include <vector>
#include "textdisplay.h"
#include "info.h"
#include <iostream>
using namespace std;
TextDisplay::TextDisplay() {
for (int i = 0; i < 15; ++i) {
vector<char> inner;
for (int ii = 0; ii < 11; ++ii)
inner.push_back(' ');
theDisplay.push_back(inner);
}
}
void TextDisplay::notify(Info info) {
if(info.x < 0 || info.x > 10 || info.y < 0 || info.y > 14)
return;
if (info.type == BlockType::Empty)
theDisplay[info.y][info.x] = ' ';
else if (info.type == BlockType::IBlock)
theDisplay[info.y][info.x] = 'I';
else if (info.type == BlockType::JBlock)
theDisplay[info.y][info.x] = 'J';
else if (info.type == BlockType::LBlock)
theDisplay[info.y][info.x] = 'L';
else if (info.type == BlockType::OBlock)
theDisplay[info.y][info.x] = 'O';
else if (info.type == BlockType::SBlock)
theDisplay[info.y][info.x] = 'S';
else if (info.type == BlockType::ZBlock)
theDisplay[info.y][info.x] = 'Z';
else if (info.type == BlockType::TBlock)
theDisplay[info.y][info.x] = 'T';
else if (info.type == BlockType::SingleBlock)
theDisplay[info.y][info.x] = '*';
else if (info.type == BlockType::HintBlock)
theDisplay[info.y][info.x] = '?';
}
TextDisplay::~TextDisplay() {}
ostream &operator<<(ostream &out, const TextDisplay &td) {
for (int i = 0; i < 15; ++i) {
out << " |";
for (int ii = 0; ii < 11; ++ii)
out << td.theDisplay[i][ii];
out << "|" << endl;
}
return out;
}