-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCode.cpp
More file actions
312 lines (256 loc) · 9.66 KB
/
TestCode.cpp
File metadata and controls
312 lines (256 loc) · 9.66 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#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;
InterfaceX UN;
//Create Input and Output objects to test
Output *pOut = new Output();;
Input *pIn = pOut->CreateInput();
//Starting the test
pOut->PrintMsg("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->PrintMsg("TEST1: Drawing Tool bar and Status bar, Click anywhere to continue");
//pIn->GetPointClicked(x,y); //Wait for any click
///////////////////////////////////////////////////////////////////////////////////
// TEST 2: Drawing all the Components with all possible states: Normal, highlighted
//
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMsg("Testing All User interface shapes");
pIn->GetPointClicked(x,y); //Wait for any click
GraphicsInfo GfxInfo; //to be used with draw function of the class Ouput
/// 2.1- AND2 Gate test
//pOut->PrintMsg("Drawing 2-input AND gate, Normal and Highlighted, Click to continue");
//Drawing Normal AND2 gate
GfxInfo.x1 = 120; GfxInfo.y1 = 120;
pOut->DrawAND2(GfxInfo);
//Drawing Highlighted AND2 gate
GfxInfo.x1 = 180+20; GfxInfo.y1 = 120;
pOut->DrawAND2(GfxInfo, true);
GfxInfo.x1 = 100 + 20; GfxInfo.y1 = 180;
pOut->DrawAND3(GfxInfo);
GfxInfo.x1 = 180 + 20; GfxInfo.y1 = 180;
pOut->DrawAND3(GfxInfo, true);
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
/// 2.2- NAND2 Gate test
GfxInfo.x1 = 100 + 20; GfxInfo.y1 = 240;
//pOut->PrintMsg("Drawing 2-input NAND gate, Normal and Highlighted, Click to continue");
pOut->DrawNAND2(GfxInfo);
GfxInfo.x1 = 180 + 20; GfxInfo.y1 = 240;
pOut->DrawNAND2(GfxInfo, true);
GfxInfo.x1 = 100 + 20; GfxInfo.y1 = 300;
pOut->DrawNAND3(GfxInfo);
GfxInfo.x1 = 180 + 20; GfxInfo.y1 = 300;
pOut->DrawNAND3(GfxInfo, true);
///TODO: Add code to draw 2-input NAND gate, Normal and Highlighted
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
/// 2.3- OR2 and NOR2 Gates test
//pOut->PrintMsg("Drawing 2-input OR and NOR gates, Normal and Highlighted, Click to continue");
GfxInfo.x1 = 260 + 20; GfxInfo.y1 = 120;
pOut->DrawOR2(GfxInfo);
GfxInfo.x1 = 340 + 20; GfxInfo.y1 = 120;
pOut->DrawOR2(GfxInfo,true);
GfxInfo.x1 = 260 + 20; GfxInfo.y1 = 180;
pOut->DrawOR3(GfxInfo);
GfxInfo.x1 = 340 + 20; GfxInfo.y1 = 180;
pOut->DrawOR3(GfxInfo,true);
///TODO: Add code to draw 2-input OR and NOR gates, Normal and Highlighted for each
GfxInfo.x1 = 260 + 20; GfxInfo.y1 = 240;
pOut->DrawNOR2(GfxInfo);
GfxInfo.x1 = 260 + 20; GfxInfo.y1 = 300;
pOut->DrawNOR2(GfxInfo, true);
GfxInfo.x1 = 340 + 20; GfxInfo.y1 = 240;
pOut->DrawNOR3(GfxInfo);
GfxInfo.x1 = 340 + 20; GfxInfo.y1 = 300;
pOut->DrawNOR3(GfxInfo, true);
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
/// 2.4- XOR2 and XNOR2 Gates test
//pOut->PrintMsg("Drawing 2-input XOR and XNOR gates, Normal and Highlighted, Click to continue");
///TODO: Add code to draw 2-input XOR and XNOR gates, Normal and Highlighted for each
GfxInfo.x1 = 420 + 20; GfxInfo.y1 = 120;
pOut->DrawXOR2(GfxInfo);
GfxInfo.x1 = 500 + 20; GfxInfo.y1 = 120;
pOut->DrawXOR2(GfxInfo,true);
GfxInfo.x1 = 420 + 20; GfxInfo.y1 = 180;
pOut->DrawXOR3(GfxInfo);
GfxInfo.x1 = 500 + 20; GfxInfo.y1 = 180;
pOut->DrawXOR3(GfxInfo,true);
///TODO: Add code to draw 2-input XOR and XNOR gates, XNORmal and Highlighted fXOR each
GfxInfo.x1 = 420 + 20; GfxInfo.y1 = 240;
pOut->DrawXNOR2(GfxInfo);
GfxInfo.x1 = 500 + 20; GfxInfo.y1 = 240;
pOut->DrawXNOR2(GfxInfo, true);
GfxInfo.x1 = 420 + 20; GfxInfo.y1 = 300;
pOut->DrawXNOR3(GfxInfo);
GfxInfo.x1 = 500 + 20; GfxInfo.y1 = 300;
pOut->DrawXNOR3(GfxInfo, true);
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
/// 2.5- Buffer and Inverter Gates test
//pOut->PrintMsg("Drawing Buffer and Inverter Gates, Normal and Highlighted, Click to continue");
GfxInfo.x1 = 580 + 20; GfxInfo.y1 = 120;
pOut->DrawBuffer(GfxInfo);
GfxInfo.x1 = 580 + 20; GfxInfo.y1 = 180;
pOut->DrawBuffer(GfxInfo,true);
GfxInfo.x1 = 640 + 20; GfxInfo.y1 = 120;
pOut->DrawInverter(GfxInfo);
GfxInfo.x1 = 640 + 20; GfxInfo.y1 = 180;
pOut->DrawInverter(GfxInfo,true);
///TODO: Add code to draw Buffer and Inverter Gates, Normal and Highlighted for each
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
GfxInfo.x1 = 580 + 20; GfxInfo.y1 = 240;
pOut->DrawSwitch(GfxInfo);
pIn->GetPointClicked(x, y);
GfxInfo.x1 = 640 + 20; GfxInfo.y1 = 240;
pOut->DrawSwitch(GfxInfo, true, false);
GfxInfo.x1 = 580 + 20; GfxInfo.y1 = 300;
pOut->DrawSwitch(GfxInfo, false, true);
GfxInfo.x1 = 640 + 20; GfxInfo.y1 = 300;
pOut->DrawSwitch(GfxInfo, true, true);
/// 2.6- AND3, NOR3, and XOR3 Gates test
//pOut->PrintMsg("Drawing 3-input AND, NOR, XOR Gates, Normal and Highlighted, Click to continue");
GfxInfo.x1 = 750 + 20; GfxInfo.y1 = 120;
pOut->DrawLED(GfxInfo);
GfxInfo.x1 = 750 + 20; GfxInfo.y1 = 180;
pOut->DrawLED(GfxInfo, true);
GfxInfo.x1 = 830 + 20; GfxInfo.y1 = 120;
pOut->DrawLED(GfxInfo, false, true);
GfxInfo.x1 = 830 + 20; GfxInfo.y1 = 180;
pOut->DrawLED(GfxInfo, true, true);
pIn->GetPointClicked(x, y); //Wait for any click
///TODO: Add code to draw 3-input AND, NOR, and XOR Gates, Normal and Highlighted for each
pOut->print();
pIn->GetPointClicked(x,y); //Wait for any click
//pOut->ClearDrawingArea();
if (!(pOut->connect(GraphicsInfo(10, 150, 450, 500))));
/// 2.7- Switch and LED test
//pOut->PrintMsg("Drawing Switch and LED, Normal and Highlighted, Click to continue");
///TODO: Add code to draw Switch and LED, Normal and Highlighted for each
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawingArea();
/// 2.8- Connections
//pOut->PrintMsg("Drawing connections, Normal, Highlighted, straight, and broken, Click to continue");
///TODO: Add code to draw connections, Normal, Highlighted, straight, and broken (all combinations)
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawingArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 3: Read strings from the user
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMsg("TEST3: Now Time to test class Input, Click anywhere to continue");
pIn->GetPointClicked(x,y); //Wait for any click
pOut->PrintMsg("Testing Input ability to read strings");
///TODO: Add code here to
// 1- Read a string from the user on the status bar and print it inside the drawing area
pIn->GetSrting(pOut);
pIn->GetPointClicked(x,y); //Wait for any click
pOut->ClearDrawingArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 4: Check for the user action
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMsg("TEST4: Testing Input ability to detect User Action, click anywhere");
ActionType ActType;
///TODO: You must add a case for each action
//Add cases for the missing actions below
do
{
ActType = pIn->GetUserAction(UN);
switch (ActType)
{
case ADD_GATE_BAR:
{
pOut->DrawGatesBar();
UN.GateBar = true;
}
break;
case ADD_AND:
{
pOut->DrawAndBar();
UN.AndBar = true;
UN.OrBar = false;
UN.XorBar = false;
}
break;
case ADD_OR:
{
pOut->DrawOrBar();
UN.OrBar = true;
UN.AndBar = false;
UN.XorBar = false;
}
break;
case ADD_XOR:
{
pOut->DrawXorBar();
UN.XorBar = true;
UN.OrBar = false;
UN.AndBar = false;
}
break;
case ADD_Buff:
pOut->PrintMsg("Action: add a buffer gate , Click anywhere");
break;
case ADD_INV:
pOut->PrintMsg("Action: add an inverter gate , Click anywhere");
break;
case ADD_AND_GATE_2:
pOut->PrintMsg("Action: add 2-input AND gate , Click anywhere");
break;
case ADD_NAND_GATE_2:
pOut->PrintMsg("Action: add 2-input NAND gate , Click anywhere");
break;
case ADD_OR_GATE_2:
pOut->PrintMsg("Action: add 2-input OR gate , Click anywhere");
break;
case ADD_NOR_GATE_2:
pOut->PrintMsg("Action: add 2-input NOR gate , Click anywhere");
break;
case ADD_XOR_GATE_2:
pOut->PrintMsg("Action: add 2-input XOR gate , Click anywhere");
break;
case ADD_XNOR_GATE_2:
pOut->PrintMsg("Action: add 2-input XNOR gate , Click anywhere");
break;
case SELECT:
pOut->PrintMsg("Action: a click on the Select Icon, Click anywhere");
break;
case STATUS_BAR:
pOut->PrintMsg("Action: a click on the Status Bar, Click anywhere");
break;
case DSN_TOOL:
pOut->PrintMsg("Action: a click on empty area in the Design Tool Bar, Click anywhere");
break;
case SIM_MODE:
{
pOut->PrintMsg("Action: Switch to Simulation Mode, creating simualtion tool bar");
pOut->CreateSimulationToolBar();
UN.Simulation = true;
}
break;
case DSN_MODE:
{pOut->PrintMsg("Action: Switch to Design Mode, creating Design tool bar");
UN.Simulation = false;
pOut->CreateDesignToolBar();}
break;
case DRWNG_AREA:
pOut->PrintMsg("Action: a click on the Drawing area, Click anywhere");
break;
case EXIT:
break;
}
}while(ActType != EXIT);
/// Exiting
pOut->PrintMsg("Action: EXIT, test is finished, click anywhere to exit");
pIn->GetPointClicked(x,y);
delete pIn;
delete pOut;
return 0;
}