-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestCode.cpp
More file actions
256 lines (192 loc) · 8.76 KB
/
TestCode.cpp
File metadata and controls
256 lines (192 loc) · 8.76 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include "GUI\Input.h"
#include "GUI\Output.h"
//This is a test code to test the Input and Output classes
int main()
{
int x,y;
//Create Input and Output objects to test
Output *pOut = new Output();
Input *pIn = pOut->CreateInput();
//Starting the test
pOut->PrintMessage("This demo is to test input and output classes, Click anywhere to start the test");
pIn->GetPointClicked(x,y); //Wait for any click
///////////////////////////////////////////////////////////////////////////////////
// TEST 1:
// Create The FULL Tool bar, the drawing area and the status bar
// This has already been done through the constrcutor of class Output
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST1: Drawing Tool bar and Status bar, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
///////////////////////////////////////////////////////////////////////////////////
// TEST 2:
// Drawing all the Figures with all possible states:
// Non-filled, Filled, and highlighted in both cases
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST2: Now we will show that Output class can draw any figure in any state, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
GfxInfo gfxInfo;//to be used with draw function of the class Ouput
Point P1, P2;
Point P3;
/// 2.1- Rectangle Test ///
/// ===================
pOut->PrintMessage("Drawing a Rectangle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x,y); //Wait for any click
// 2.1.1 - Drawing non-filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> non-filled, Click two points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
gfxInfo.BorderWdth = 5;
gfxInfo.DrawClr = BLACK; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawRect(P1, P2, gfxInfo, false);
// 2.1.2 - Drawing highlighted non-filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->DrawRect(P1, P2, gfxInfo, true);
// 2.1.3 - Drawing a filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> filled, Click two points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
gfxInfo.BorderWdth = 6;
gfxInfo.DrawClr = BLUE; //any color for border
gfxInfo.FillClr = GREEN;//any color for filling
gfxInfo.isFilled = true;//Figure is filled
pOut->DrawRect(P1, P2, gfxInfo, false);
// 2.1.4 - Drawing a highlighted filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted filled, Click to Highlight");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->DrawRect(P1, P2, gfxInfo, true);
pOut->PrintMessage("Drawing a Rectangle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
/// 2.2- Square Test ///
/// ==============
pOut->PrintMessage("Drawing a Square, normal and Highlighted, Click to continue");
pIn->GetPointClicked(x,y); //Wait for any click
/////////////////////////////////////////////////
pOut->PrintMessage("Drawing a Square, normal , click one point");
pIn->GetPointClicked(P1.x, P1.y);
gfxInfo.BorderWdth = 5;
gfxInfo.DrawClr = BLACK; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawSquare(P1, gfxInfo, false);
pOut->PrintMessage("Drawing a Square, Highlighted, click to Highlight");
pIn->GetPointClicked(x, y);
pOut->DrawSquare(P1, gfxInfo, true);
/////////////////////////////////////////////////
///TODO: Add code to draw Square, Normal and Highlighted
pOut->PrintMessage("Drawing a Square Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
/// 2.3- Triangle Test ///
/// ===================
pOut->PrintMessage("Drawing a Triangle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x,y); //Wait for any click
////////////////////////////////////////////////////
pOut->PrintMessage("Drawing a Triangle ==> non-filled, Click Three Points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
pIn->GetPointClicked(P3.x, P3.y);
gfxInfo.BorderWdth = 5;
gfxInfo.DrawClr = BLACK; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawTriangle(P1, P2, P3, gfxInfo, false);
pOut->PrintMessage("Drawing a Triangle ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x, y);
pOut->DrawTriangle(P1, P2, P3, gfxInfo, true);
pOut->PrintMessage("Drawing a Triangle ==> filled, Click three points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
pIn->GetPointClicked(P3.x, P3.y);
gfxInfo.BorderWdth = 6;
gfxInfo.DrawClr = BLUE; //any color for border
gfxInfo.FillClr = GREEN;//any color for filling
gfxInfo.isFilled = true;//Figure is filled
pOut->DrawTriangle(P1, P2, P3, gfxInfo, false);
pOut->PrintMessage("Drawing a Triangle ==> Highlighted filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawTriangle(P1, P2, P3, gfxInfo, true);
///////////////////////////////////////////////////
///TODO: Add code to draw Triangle in all possible states
pOut->PrintMessage("Drawing a Triangle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
/// 2.4- Hexagon Test ///
/// ===================
pOut->PrintMessage("Drawing a Hexagon, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x,y); //Wait for any click
///TODO: Add code to draw Hexagon in all possible states
pOut->PrintMessage("Drawing a Hexagon Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
/// 2.5- Circle Test ///
/// ===================
pOut->PrintMessage("Drawing an Circle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x,y); //Wait for any click
///TODO: Add code to draw Circle in all possible states
pOut->PrintMessage("Drawing a Circle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 3:
// Input Class: Read strings from the user
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST3: Now Time to test class Input, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->PrintMessage("Testing Input ability to read strings");
///TODO: Add code here to
// 1- Read a string from the user on the status bar
// 2- After reading the string clear the status bar
// 3- print on the status bar "You Entered" then print the string
/////////////////////////////////////////////////////////////////
string s1 = pIn->GetSrting(pOut);
pOut->PrintMessage(" You Entered :" + s1 + " ,Click to continue");
//////////////////////////////////////////////////////////////////
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 4:
// Input Class : Check for the user action
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST4: Testing Input ability to detect User Action, click anywhere");
ActionType ActType;
///TODO:
//You must add a case for each action (both Draw mode and Play mode actions)
//Add cases for the missing actions below
do
{
ActType = pIn->GetUserAction();
switch (ActType)
{
case DRAW_RECT:
pOut->PrintMessage("Action: Draw a Rectangle , Click anywhere");
break;
case STATUS:
pOut->PrintMessage("Action: a click on the Status Bar, Click anywhere");
break;
case DRAWING_AREA:
pOut->PrintMessage("Action: a click on the Drawing Area, Click anywhere");
break;
case EMPTY:
pOut->PrintMessage("Action: a click on empty area in the Design Tool Bar, Click anywhere");
break;
case TO_DRAW:
pOut->PrintMessage("Action: Switch to Draw Mode, creating simualtion tool bar");
pOut->CreateDrawToolBar();
break;
case TO_PLAY:
pOut->PrintMessage("Action: Switch to Play Mode, creating Design tool bar");
pOut->CreatePlayToolBar();
break;
///TODO: Add more cases for the other action types
case EXIT:
break;
}
}while(ActType != EXIT);
/// Exiting
pOut->PrintMessage("Action: EXIT, test is finished, click anywhere to exit");
pIn->GetPointClicked(x,y);
delete pIn;
delete pOut;
return 0;
}