-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextView.cc
executable file
·98 lines (90 loc) · 1.68 KB
/
TextView.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "TextView.h"
#include "View.h"
#include "iostream"
using namespace std;
TextView::TextView(int rows, int columns) : rows(rows), columns(columns){
for (int i = 0; i < rows; ++i)
{
vector<char>row;
for (int j = 0; j < columns; ++j)
{
row.emplace_back(' ');
}
boardDisplay.emplace_back(row);
}
}
void TextView::notify(int row, int column, char ch)
{
boardDisplay[row][column] = ch;
}
void TextView::update(int level, int score, int hiScore, char ch){
cout << "Level: " << level << endl;
cout << "Score: " << score << endl;
cout << "Hiscore: " << hiScore << endl;
cout << "____________" << endl;
for(int i = 0; i < rows; ++i) // Displaying the boards
{
cout << "|";
for(int j = 0; j < columns; ++j)
{
cout << boardDisplay[i][j];
}
cout << "|" << endl;
}
cout << "¯¯¯¯¯¯¯¯¯¯¯¯" << endl;
cout << "Next:" << endl;
if(ch == 'I') // printing out the next block
{
cout << "IIII" << endl;
}
else if(ch == 'J')
{
cout << "J" << endl;
cout << "JJJ";
}
else if(ch == 'L')
{
cout << " L" << endl;
cout << "LLL";
}
else if(ch == 'O')
{
cout << "OO" << endl;
cout << "OO";
}
else if(ch == 'S')
{
cout << " SS" << endl;
cout << "SS";
}
else if(ch == 'T')
{
cout << "TTT" << endl;
cout << " T";
}
else if(ch == 'Z')
{
cout << "ZZ" << endl;
cout << " ZZ";
}
else if(ch == '*')
{
cout << "*" << endl;
}
else if(ch == 'N'){
cout << " N" << endl;
cout << " N" << endl;
cout << " N" << endl;
cout << "N" << endl;
}
else if(ch == 'C'){
cout << " C" << endl;
cout << "CCC" << endl;
cout << " C" << endl;
}
else if(ch == 'E')
{
cout << "No more blocks on this level" << endl;
}
cout << endl;
}