-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlock.h
133 lines (124 loc) · 2.52 KB
/
Block.h
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#pragma once
class Block
{
public:
Block(unsigned char clr, unsigned char **board);
virtual bool canMoveDown() = 0;
virtual bool canMoveLeft() = 0;
virtual bool canMoveRight() = 0;
virtual bool canTurn() = 0;
virtual void moveDown() = 0;
virtual void moveLeft() = 0;
virtual void moveRight() = 0;
virtual void turn() = 0;
protected:
char row;
char col;
unsigned char dir;
unsigned char clr;
unsigned char **board;
};
class BlockI : public Block
{
public:
BlockI(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
private:
bool passable(char row, char col);
void show();
void clear();
};
class BlockJ : public Block
{
public:
BlockJ(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
};
class BlockL : public Block
{
public:
BlockL(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
};
class BlockO : public Block
{
public:
BlockO(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
};
class BlockS : public Block
{
public:
BlockS(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
private:
void show();
void clear();
};
class BlockT : public Block
{
public:
BlockT(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
private:
void show();
void clear();
};
class BlockZ : public Block
{
public:
BlockZ(unsigned char clr, unsigned char **board);
void moveDown();
void moveLeft();
void moveRight();
bool canMoveDown();
bool canMoveLeft();
bool canMoveRight();
void turn();
bool canTurn();
private:
void show();
void clear();
};