-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyramid.cpp
77 lines (68 loc) · 1.37 KB
/
Pyramid.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
74
75
76
77
#include <iostream>
#include "Pyramid.h"
#include "Constants.h"
using namespace std;
/*
* The pyramid.
*
* #
* ###
*
*/
Pyramid::Pyramid()
: Shape ()
{
string pyramid0[3] =
{ " # ",
"###",
" " };
string pyramid1[3] =
{ " # ",
" ##",
" # " };
string pyramid2[3] =
{ " ",
"###",
" # " };
string pyramid3[3] =
{ " # ",
"## ",
" # " };
// TODO: Somewhat broken. Why "1"s in the first parameter? It's the rotatation number, no?
// The code ROTATES in the direction specified by the first argument. The "1" means rotate
// rotate 'right'. SIGH!
init_shape(1,3,pyramid0);
init_shape(1,3,pyramid1);
init_shape(1,3,pyramid2);
init_shape(1,3,pyramid3);
}
void Pyramid::rotate_left()
{
rotate(-1);
}
void Pyramid::rotate_right()
{
rotate(1);
}
// NOTE: The "3" is a hardcoded.
void Pyramid::draw()
{
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
cout << shapedata(row, col);
}
cout << endl;
}
}
int Pyramid::get_piece_type()
{
return(PYRAMID); // This is the constant for a Pyramid
}
void Pyramid::init_shape(int rotation, int square_size, string in_shape_data[]) {
rotate(rotation);
height() = square_size;
width() = square_size;
for (int i = 0; i < square_size; i++) {
shapedata() += in_shape_data[i];
}
}