-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestshape.cpp
82 lines (66 loc) · 1.92 KB
/
testshape.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
78
79
80
81
82
/*
* This is a low-level test of the shape data (the non-SDL shape classes).
* NOTE: No grid is used. The shapes are just drawn.
*/
#include "Square.h"
#include "Pyramid.h"
#include "LeftSlant.h"
#include "RightSlant.h"
#include "LongRow.h"
#include "LeftEll.h"
#include "RightEll.h"
#include "Constants.h"
#include <iostream>
#include <vector>
using namespace std;
int main( int argc, char* args[] )
{
vector<Shape *> shapes_vector;
Shape* shape;
shape = new Square();
shapes_vector.push_back(shape);
shape = new Pyramid();
shapes_vector.push_back(shape);
shape = new LeftSlant();
shapes_vector.push_back(shape);
shape = new RightSlant();
shapes_vector.push_back(shape);
shape = new LongRow();
shapes_vector.push_back(shape);
shape = new LeftEll();
shapes_vector.push_back(shape);
shape = new RightEll();
shapes_vector.push_back(shape);
char choice;
int selected_shape;
while (true) {
selected_shape = -1;
cout << "(1) Square, (2) Pyramid," << endl << "(3) Left Slant, (4) Right Slant," << endl << "(5) Long Row," << endl << "(6) Left Ell, (7) Right Ell," << endl << "(q)uit" << endl;
cin >> choice;
switch (choice) {
case '1': selected_shape = 0; break;
case '2': selected_shape = 1; break;
case '3': selected_shape = 2; break;
case '4': selected_shape = 3; break;
case '5': selected_shape = 4; break;
case '6': selected_shape = 5; break;
case '7': selected_shape = 6; break;
default:
break;
}
if (selected_shape == -1) {
break;
}
cout << "(l)eft rotate, (r)ight rotate, (d)raw" << endl;
cin >> choice;
if (choice == 'l') {
shapes_vector[selected_shape]->rotate_left();
shapes_vector[selected_shape]->draw();
} else if (choice == 'r'){
shapes_vector[selected_shape]->rotate_right();
shapes_vector[selected_shape]->draw();
} else {
shapes_vector[selected_shape]->draw();
}
}
}