Browse Source

Initial commit Testing

Jose Ortiz 10 years ago
commit
9326184467
10 changed files with 2175 additions and 0 deletions
  1. 27
    0
      Testing.pro
  2. 839
    0
      functions.cpp
  3. 31
    0
      functions.h
  4. 66
    0
      labTesting.md
  5. 69
    0
      main.cpp
  6. 818
    0
      mainwindow.cpp
  7. 99
    0
      mainwindow.h
  8. 193
    0
      mainwindow.ui
  9. 11
    0
      secondwindow.cpp
  10. 22
    0
      secondwindow.h

+ 27
- 0
Testing.pro View File

@@ -0,0 +1,27 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2014-07-03T13:18:44
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core gui
8
+
9
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+TARGET = Testing
12
+TEMPLATE = app
13
+
14
+
15
+SOURCES += main.cpp\
16
+        mainwindow.cpp \
17
+    secondwindow.cpp \
18
+    functions.cpp
19
+
20
+HEADERS  += mainwindow.h \
21
+    secondwindow.h \
22
+    functions.h
23
+
24
+FORMS    += mainwindow.ui
25
+
26
+RESOURCES += \
27
+    images.qrc

+ 839
- 0
functions.cpp View File

@@ -0,0 +1,839 @@
1
+#include "mainwindow.h"
2
+#include "ui_mainwindow.h"
3
+
4
+#include <QDebug>
5
+#include <QString>
6
+#include <cstdlib>
7
+
8
+#include <QMessageBox>
9
+#include <QMap>
10
+#include "functions.h"
11
+#ifdef _WIN32
12
+#include <windows.h>
13
+#else
14
+#include <unistd.h>
15
+#endif
16
+
17
+
18
+// =========================================================
19
+// Sort Functions
20
+// =========================================================
21
+
22
+bool validateSorts(const QString &a, const QString &b, const QString &c) {
23
+     return (a.length() * b.length() * c.length() > 0);
24
+}
25
+
26
+
27
+void mySortAlpha(QString &a, QString &b, QString &c) {
28
+    if (a > b ) {
29
+        if (c > a)      swap(b,c);
30
+        else if (b > c) swap(a,b);
31
+        else {
32
+            QString tmp = a;
33
+            a = b; b = c; c = tmp;
34
+        }
35
+    }
36
+    else {
37
+        if (a > c) {
38
+            QString tmp = c;
39
+            c = b;  b = a; a = tmp;
40
+        }
41
+        else if (b > c) swap(b,c);
42
+        else {
43
+            // they are already in order :-)
44
+        }
45
+    }
46
+}
47
+
48
+void mySortBeta(QString &a, QString &b, QString &c) {
49
+    if (a > b ) {
50
+        if (c > a)      swap(a,b);
51
+        else if (b > c) swap(a,c);
52
+        else {
53
+            QString tmp = a;
54
+            a = b; b = c; c = tmp;
55
+        }
56
+    }
57
+    else {
58
+        if (a > c) {
59
+            QString tmp = c;
60
+            c = b;  b = a; a = tmp;
61
+        }
62
+        else if (b > c) swap(b,c);
63
+        else {
64
+            // they are already in order :-)
65
+        }
66
+    }
67
+}
68
+
69
+void mySortGamma(QString &a, QString &b, QString &c) {
70
+    if (a > b ) {
71
+        if (c > a)      swap(a,b);
72
+        else if (b > c) swap(a,c);
73
+        else {
74
+            QString tmp = a;
75
+            a = c; c = b; b = tmp;
76
+        }
77
+    }
78
+    else {
79
+        if (a > c) {
80
+            QString tmp = c;
81
+            c = b;  b = a; a = tmp;
82
+        }
83
+        else if (b > c) swap(b,c);
84
+        else {
85
+            // they are already in order :-)
86
+        }
87
+    }
88
+}
89
+
90
+void mySortDelta(QString &a, QString &b, QString &c) {
91
+    if (a < b ) {
92
+        if (c < a)      swap(a,b);
93
+        else if (b < c) swap(a,c);
94
+        else {
95
+            QString tmp = a;
96
+            a = b; b = c; c = tmp;
97
+        }
98
+    }
99
+    else {
100
+        if (a > c) {
101
+            QString tmp = c;
102
+            c = b;  b = a; a = tmp;
103
+        }
104
+        else if (b > c) swap(b,c);
105
+        else {
106
+            // they are already in order :-)
107
+        }
108
+    }
109
+}
110
+
111
+
112
+//This is the correct dice roller
113
+void MainWindow::diceAlpha(){
114
+    QString a, b;
115
+
116
+    //This loop is used to simulate the dice rolling by
117
+    //changing the images at a slowing down speed
118
+    for (int i = 0; i<=150000 ; i=i+5000){
119
+        usleep(i);
120
+
121
+        //First dice image. Since we want random pictures
122
+        //on each iteration, we get a random number, converted
123
+        //it to string and append it to others string that
124
+        //conform the names of the dices
125
+        a = ":/images/resources/d";
126
+        a.append(QString::number(rand()%6 + 1));
127
+        a.append(".png");
128
+
129
+        b = ":/images/resources/d";
130
+        b.append(QString::number(rand()%6 + 1));
131
+        b.append(".png");
132
+
133
+        //We load the images and check if there is no problem with them
134
+        if(!dice1.load(a) || !dice2.load(b)){
135
+            qDebug() << "Error2 Loading image";
136
+        }
137
+
138
+        //Finally we set the labels with the random dice images
139
+        label[3]->setPixmap(QPixmap::fromImage(dice1));
140
+        label[4]->setPixmap(QPixmap::fromImage(dice2));
141
+
142
+// Is there an option to see the changes of the dice/label
143
+// in this function and no just when we get out of it?
144
+
145
+//        Fail attempts
146
+//        layout->update();
147
+//        repaint();
148
+//        window->repaint();
149
+
150
+//        label[3]->repaint();
151
+//        label[3]->update();
152
+//        label[3]->hide();
153
+//        label[3]->show();
154
+//        label[3]->setVisible(false);
155
+//        label[3]->setVisible(true);
156
+
157
+//        layout->update();
158
+//        update();
159
+//        window->update();
160
+
161
+        window->hide();
162
+        window->show();
163
+    }
164
+
165
+    //Finally, we set the result of the sum of the dices.
166
+    QString a2 = (QString)a[20];
167
+    QString b2 = (QString)b[20];
168
+    int total = a2.toInt() + b2.toInt();
169
+    line[0]->setText(QString::number(total));
170
+}
171
+
172
+//This version sums the first dice twice
173
+void MainWindow::diceBeta(){
174
+    QString a, b;
175
+
176
+    for (int i = 0; i<=150000 ; i=i+5000){
177
+        usleep(i);
178
+
179
+        a = ":/images/resources/d";
180
+        a.append(QString::number(rand()%6 + 1));
181
+        a.append(".png");
182
+
183
+        b = ":/images/resources/d";
184
+        b.append(QString::number(rand()%6 + 1));
185
+        b.append(".png");
186
+
187
+        if(!dice1.load(a) || !dice2.load(b)){
188
+            qDebug() << "Error2 Loading image";
189
+        }
190
+
191
+        label[3]->setPixmap(QPixmap::fromImage(dice1));
192
+        label[4]->setPixmap(QPixmap::fromImage(dice2));
193
+
194
+// Is there an option to see the changes of the dice/label
195
+// in this function and no just when we get out of it?
196
+        window->hide();
197
+        window->show();
198
+    }
199
+
200
+    int total = a[20].digitValue() + a[20].digitValue();
201
+    line[0]->setText(QString::number(total));
202
+}
203
+
204
+//This one substracts the second dice to the first one
205
+void MainWindow::diceGamma(){
206
+    QString a, b;
207
+
208
+    for (int i = 0; i<=150000 ; i=i+5000){
209
+        usleep(i);
210
+
211
+        a = ":/images/resources/d";
212
+        a.append(QString::number(rand()%6 + 1));
213
+        a.append(".png");
214
+
215
+        b = ":/images/resources/d";
216
+        b.append(QString::number(rand()%6 + 1));
217
+        b.append(".png");
218
+
219
+        if(!dice1.load(a) || !dice2.load(b)){
220
+            qDebug() << "Error2 Loading image";
221
+        }
222
+
223
+        label[3]->setPixmap(QPixmap::fromImage(dice1));
224
+        label[4]->setPixmap(QPixmap::fromImage(dice2));
225
+
226
+// Is there an option to see the changes of the dice/label
227
+// in this function and no just when we get out of it?
228
+        window->hide();
229
+        window->show();
230
+    }
231
+
232
+    QString a2 = (QString)a[20];
233
+    QString b2 = (QString)b[20];
234
+    int total = a2.toInt() - b2.toInt();
235
+    line[0]->setText(QString::number(total));
236
+}
237
+
238
+//This one tooks the number 6 as a 12
239
+void MainWindow::diceDelta(){
240
+    QString a, b;
241
+
242
+    for (int i = 0; i<=150000 ; i=i+5000){
243
+        usleep(i);
244
+
245
+        a = ":/images/resources/d";
246
+        a.append(QString::number(rand()%6 + 1));
247
+        a.append(".png");
248
+
249
+        b = ":/images/resources/d";
250
+        b.append(QString::number(rand()%6 + 1));
251
+        b.append(".png");
252
+
253
+        if(!dice1.load(a) || !dice2.load(b)){
254
+            qDebug() << "Error2 Loading image";
255
+        }
256
+
257
+        label[3]->setPixmap(QPixmap::fromImage(dice1));
258
+        label[4]->setPixmap(QPixmap::fromImage(dice2));
259
+
260
+// Is there an option to see the changes of the dice/label
261
+// in this function and no just when we get out of it?
262
+        window->hide();
263
+        window->show();
264
+    }
265
+
266
+    int x, y;
267
+    QString a2 = (QString)a[20];
268
+    QString b2 = (QString)b[20];
269
+    if (a2.toInt() == 6){
270
+        x = 12;
271
+    }
272
+    else{
273
+        x = a2.toInt();
274
+    }
275
+    if (b2.toInt() == 6){
276
+        y = 12;
277
+    }
278
+    else{
279
+        y = b2.toInt();
280
+    }
281
+
282
+    int total = x + y;
283
+    line[0]->setText(QString::number(total));
284
+}
285
+
286
+// =========================================================
287
+// Rock Paper Scissor Functions
288
+// =========================================================
289
+
290
+
291
+///
292
+/// \brief RPSAlpha
293
+/// \param p1
294
+/// \param p2
295
+/// \param score1
296
+/// \param score2
297
+/// \return
298
+///
299
+
300
+int RPSAlpha(char p1, char p2, int &score1, int &score2) {
301
+    p1 = toupper(p1);
302
+    p2 = toupper(p2);
303
+    if ( p1 == 'P' ) {
304
+        if ( p2 == 'P' ) return 0;
305
+        else if (p2 == 'R') {
306
+            score1++; return 1;
307
+        }
308
+        else {
309
+            score2++; return 2;
310
+        }
311
+    }
312
+    else if (p1 == 'R') {
313
+        if ( p2 == 'R' ) return 0;
314
+        else if (p2 == 'S') {
315
+            score1++;    return 1;
316
+        }
317
+        else {
318
+            score2++;    return 2;
319
+        }
320
+    }
321
+    else {
322
+        if ( p2 == 'S' ) return 0;
323
+        else if (p2 == 'P') {
324
+            score1++;    return 1;
325
+        }
326
+        else {
327
+            score2++;    return 2;
328
+        }
329
+    }
330
+}
331
+
332
+
333
+///
334
+/// \brief RPSBeta
335
+/// \param p1
336
+/// \param p2
337
+/// \param score1
338
+/// \param score2
339
+/// \return
340
+///
341
+
342
+int RPSBeta(char p1, char p2, int &score1, int &score2) {
343
+    p1 = toupper(p1);
344
+    p2 = toupper(p2);
345
+    if ( p1 == 'P' ) {
346
+        if ( p2 == 'S' ) return 0;
347
+        else if (p2 == 'R') {
348
+            score1++; return 1;
349
+        }
350
+        else {
351
+            score2++; return 2;
352
+        }
353
+    }
354
+    else if (p1 == 'R') {
355
+        if ( p2 == 'S' ) return 0;
356
+        else if (p2 == 'P') {
357
+            score1++;    return 1;
358
+        }
359
+        else {
360
+            score2++;    return 2;
361
+        }
362
+    }
363
+    else {
364
+        if ( p2 == 'S' ) return 0;
365
+        else if (p2 == 'R') {
366
+            score1++;    return 1;
367
+        }
368
+        else {
369
+            score2++;    return 2;
370
+        }
371
+    }
372
+}
373
+
374
+
375
+///
376
+/// \brief RPSGamma
377
+/// \param p1
378
+/// \param p2
379
+/// \param score1
380
+/// \param score2
381
+/// \return
382
+///
383
+
384
+int RPSGamma(char p1, char p2, int &score1, int &score2) {
385
+    p1 = toupper(p1);
386
+    p2 = toupper(p2);
387
+    if ( p1 == 'P' ) {
388
+        if ( p2 == 'P' ) return 0;
389
+        else if (p2 == 'S') {
390
+            score1++; return 1;
391
+        }
392
+        else {
393
+            score2++; return 2;
394
+        }
395
+    }
396
+    else if (p1 == 'R') {
397
+        if ( p2 == 'R' ) return 0;
398
+        else if (p2 == 'P') {
399
+            score1++;    return 1;
400
+        }
401
+        else {
402
+            score2++;    return 2;
403
+        }
404
+    }
405
+    else {
406
+        if ( p2 == 'P' ) return 0;
407
+        else if (p2 == 'S') {
408
+            score1++;    return 1;
409
+        }
410
+        else {
411
+            score2++;    return 2;
412
+        }
413
+    }
414
+}
415
+
416
+///
417
+/// \brief RPSDelta
418
+/// \param p1
419
+/// \param p2
420
+/// \param score1
421
+/// \param score2
422
+/// \return
423
+///
424
+
425
+int RPSDelta(char p1, char p2, int &score1, int &score2) {
426
+    p1 = toupper(p1);
427
+    p2 = toupper(p2);
428
+    if ( p1 == 'P' ) {
429
+        if ( p2 == 'P' ) return 0;
430
+        else if (p2 == 'S') {
431
+            score2++; return 1;
432
+        }
433
+        else {
434
+            score1++; return 2;
435
+        }
436
+    }
437
+    else if (p1 == 'R') {
438
+        if ( p2 == 'R' ) return 0;
439
+        else if (p2 == 'P') {
440
+            score2++;    return 1;
441
+        }
442
+        else {
443
+            score1++;    return 2;
444
+        }
445
+    }
446
+    else {
447
+        if ( p2 == 'P' ) return 0;
448
+        else if (p2 == 'S') {
449
+            score2++;    return 1;
450
+        }
451
+        else {
452
+            score1++;    return 2;
453
+        }
454
+    }
455
+}
456
+
457
+// =========================================================
458
+// Check Words Functions
459
+// =========================================================
460
+
461
+
462
+
463
+QMap<int,QString> M;
464
+
465
+///
466
+/// \brief initCheckWMaps: initialize the values in the dictionary that is used throughout
467
+///                        the check functions.
468
+///
469
+
470
+void initCheckWMaps() {
471
+
472
+    M[1] = "one";       M[2] = "two";       M[3]  = "three";      M[4] = "four";
473
+    M[5]  = "five";     M[6] = "six";
474
+    M[7] = "seven";     M[8] = "eight";     M[9]  = "nine";       M[10] = "ten";
475
+    M[11] = "eleven";   M[12] = "twelve";   M[13] = "thirteen";   M[14] = "fourteen";
476
+    M[15] = "fifteen";  M[16] = "sixteen";  M[17] = "seventeen";  M[18] = "eighteen";
477
+    M[19] = "nineteen";
478
+    M[20] = "twenty";   M[30] = "thirty";   M[40] = "fourty";   M[50] = "fifty";
479
+    M[60] = "sixty";    M[70] = "seventy";  M[80] = "eighty";   M[90] = "ninety";
480
+}
481
+
482
+
483
+///
484
+/// \brief validateCheckQty: determines is entered text is a valid number in [0,999999999]
485
+/// \param st text entered by the user
486
+/// \param qty text converted to integer
487
+/// \return true if the entered text is valid
488
+///
489
+
490
+bool validateCheckQty(QString st, unsigned int &qty) {
491
+    int i = 0;
492
+    for (i = 0; i < st.length() ; i++) {
493
+        if (!st[i].isDigit()) return false;
494
+    }
495
+
496
+    if (i > 9) return false;
497
+
498
+    qty = st.toInt();
499
+    return true;
500
+}
501
+
502
+///
503
+/// \brief wordForNumber: Given a number n in [0,999] returns the word equivalent
504
+/// \param n: the number
505
+/// \return a Qstring containing the number in words
506
+///
507
+
508
+QString wordForNumber(int n) {
509
+    QString st;
510
+
511
+    int tens = n % 100;
512
+    if (tens == 0)
513
+        st = "";
514
+    else if (tens <= 20)
515
+        st = M[n];
516
+    else {
517
+        st = M[10 * (tens/10)];
518
+        if (tens % 10)
519
+            st.append(" "  + M[tens % 10]);
520
+    }
521
+
522
+    n = n / 100;
523
+    if (n) st.prepend(M[n % 10] + " hundred" + (st.length() > 0 ? " " : ""));
524
+
525
+    return st;
526
+}
527
+
528
+
529
+///
530
+/// \brief checkWAlpha: One of the functions to convert a number in [0,999999999] to words
531
+/// \param n: the number
532
+/// \return a Qstring containing the number in words
533
+///
534
+
535
+QString checkWAlpha(int n) {
536
+    QString st;
537
+
538
+    // the cents
539
+    st = wordForNumber(n % 1000);
540
+
541
+    // the thousands
542
+    n = n / 1000;
543
+    if (n % 1000) st.prepend( wordForNumber(n % 1000) + " thousand" +  (st.length() > 0 ? " " : ""));
544
+
545
+    // the millions
546
+    n = n / 1000;
547
+    if (n % 1000) st.prepend( wordForNumber(n % 1000) + " million" +  (st.length() > 0 ? " " : ""));
548
+
549
+    return st;
550
+}
551
+
552
+///
553
+/// \brief checkWBeta: One of the functions to convert a number in [0,999999999] to words
554
+/// \param n: the number
555
+/// \return a Qstring containing the number in words
556
+///
557
+
558
+QString checkWBeta(int n) {
559
+    QString st;
560
+
561
+    st = wordForNumber(n % 1000);
562
+    n = n / 1000;
563
+    if (n % 1000) st.append( wordForNumber(n % 1000) + " thousand" +  (st.length() > 0 ? " " : ""));
564
+    n = n / 1000;
565
+    if (n % 1000) st.append( wordForNumber(n % 1000) + " million" +  (st.length() > 0 ? " " : ""));
566
+
567
+    return st;
568
+}
569
+
570
+///
571
+/// \brief checkWGamma: One of the functions to convert a number in [0,999999999] to words
572
+/// \param n: the number
573
+/// \return a Qstring containing the number in words
574
+///
575
+
576
+QString checkWGamma(int n) {
577
+    QString st;
578
+
579
+    st = wordForNumber(n % 10);
580
+    n = n / 1000;
581
+    if (n % 1000) st.append( wordForNumber(n % 10) + " thousand" +  (st.length() > 0 ? " " : ""));
582
+    n = n / 1000;
583
+    if (n % 1000) st.append( wordForNumber(n % 10) + " million" +  (st.length() > 0 ? " " : ""));
584
+
585
+    return st;
586
+}
587
+
588
+///
589
+/// \brief checkWDelta: One of the functions to convert a number in [0,999999999] to words
590
+/// \param n: the number
591
+/// \return a Qstring containing the number in words
592
+///
593
+
594
+
595
+QString checkWDelta(int n) {
596
+    QString st;
597
+
598
+    n /= 10;
599
+    st = wordForNumber(n % 1000);
600
+    n = n / 1000;
601
+    if (n % 1000) st.prepend( wordForNumber(n % 1000) + " thousand" +  (st.length() > 0 ? " " : ""));
602
+    n = n / 1000;
603
+    if (n % 1000) st.prepend( wordForNumber(n % 1000) + " million" +  (st.length() > 0 ? " " : ""));
604
+
605
+    return st;
606
+}
607
+
608
+
609
+// =========================================================
610
+// Zulu Functions
611
+// =========================================================
612
+
613
+
614
+bool validZuluTime(const QString &time, const QString &zone, int &hours, int &minutes) {
615
+    int i = 0;
616
+    for (i = 0; i< time.size(); i++)
617
+        if (!time[i].isDigit()) return false;
618
+
619
+    if (i != 4) return false;
620
+    hours   = time.mid(0,2).toInt();
621
+    minutes = time.mid(2,2).toInt();
622
+
623
+    if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59)
624
+        return false;
625
+
626
+    if (zone.length() < 1 || !zone[0].isLetter()  || toupper(zone.toStdString()[0]) ==  'J') return false;
627
+    return true;
628
+}
629
+
630
+//This is the correct one
631
+
632
+QString zuluAlpha(int hours, int minutes, char zone) {
633
+    int diff = 0;
634
+
635
+    if (zone <= 'I')         diff = zone - 'A' + 1;
636
+    else if (zone <= 'M')    diff = 10 + (zone - 'K');
637
+    else if (zone <= 'Y')    diff = -(zone - 'N' + 1);
638
+    else                     diff = 0;
639
+
640
+    hours = (hours + (24 + diff) ) % 24;
641
+
642
+    return QString::number(hours) + QString::number(minutes);
643
+}
644
+
645
+QString zuluBeta(int hours, int minutes, char zone) {
646
+    int diff = 0;
647
+
648
+    if (zone <= 'I')         diff = zone - 'B' + 1;
649
+    else if (zone <= 'M')    diff = 10 + (zone - 'M');
650
+    else if (zone <= 'Y')    diff = -(zone - 'N');
651
+    diff = 0;
652
+
653
+    hours = (hours + (24 + diff) ) % 24;
654
+
655
+    return QString::number(hours)  + QString::number(minutes);
656
+}
657
+
658
+QString zuluGamma(int hours, int minutes, char zone) {
659
+    int diff = 0;
660
+
661
+    if (zone <= 'I')          diff = zone - 'A' + 1;
662
+    else if (zone <= 'M')     diff = 10 + (zone - 'M');
663
+    else if (zone <= 'Y')     diff = -(zone - 'N');
664
+    else                      diff = 0;
665
+
666
+    hours = (hours + (24 - diff) ) % 24;
667
+
668
+    return QString::number(hours) + QString::number(minutes);
669
+}
670
+
671
+QString zuluDelta(int hours, int minutes, char zone) {
672
+    int diff = 0;
673
+
674
+    if (zone <= 'M')        diff = zone - 'B' + 1;
675
+    else if (zone <= 'Y')   diff = -(zone - 'N');
676
+    else                    diff = 0;
677
+
678
+    hours = (hours + (24 - diff) ) % 24;
679
+
680
+    return QString::number(hours)  + QString::number(minutes);
681
+}
682
+
683
+
684
+
685
+// =========================================================
686
+// APFT Functions
687
+// =========================================================
688
+
689
+
690
+//This it the correct one
691
+
692
+void MainWindow::APFTAlpha(){
693
+    //For each one of these variables we apply the formula that they use
694
+    //to set the points
695
+    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
696
+
697
+    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
698
+
699
+    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
700
+    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
701
+
702
+    //Since the maximum of points that one can obtain
703
+    //on each excercise type is 100, we restrict it
704
+    if (sit_ups > 100){
705
+        sit_ups = 100;
706
+    }
707
+    else if (sit_ups < 0){
708
+        sit_ups = 0;
709
+    }
710
+    if (push_ups > 100){
711
+        push_ups = 100;
712
+    }
713
+    else if (push_ups < 0){
714
+        push_ups = 0;
715
+    }
716
+    if (two_mile_run > 100){
717
+        two_mile_run = 100;
718
+    }
719
+    else if (two_mile_run < 0){
720
+        two_mile_run = 0;
721
+    }
722
+
723
+    //Finally we set the outputs.
724
+    line[3]->setText(QString::number(sit_ups));
725
+    line[4]->setText(QString::number(push_ups));
726
+    line[5]->setText(QString::number(two_mile_run));
727
+    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
728
+    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
729
+        label[7]->setText("PASS");
730
+    }
731
+    else{
732
+        label[7]->setText("FAIL");
733
+    }
734
+}
735
+
736
+//This one do not check if the number is greater than 100
737
+
738
+void MainWindow::APFTBeta(){
739
+    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
740
+
741
+    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
742
+
743
+    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
744
+    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
745
+
746
+    line[3]->setText(QString::number(sit_ups));
747
+    line[4]->setText(QString::number(push_ups));
748
+    line[5]->setText(QString::number(two_mile_run));
749
+    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
750
+    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
751
+        line[7]->setText("PASS");
752
+    }
753
+    else{
754
+        line[7]->setText("FAIL");
755
+    }
756
+}
757
+
758
+//This one switch the results
759
+
760
+void MainWindow::APFTGamma(){
761
+    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
762
+    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
763
+    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
764
+    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
765
+
766
+    if (sit_ups > 100){
767
+        sit_ups = 100;
768
+    }
769
+    else if (sit_ups < 0){
770
+        sit_ups = 0;
771
+    }
772
+    if (push_ups > 100){
773
+        push_ups = 100;
774
+    }
775
+    else if (push_ups < 0){
776
+        push_ups = 0;
777
+    }
778
+    if (two_mile_run > 100){
779
+        two_mile_run = 100;
780
+    }
781
+    else if (two_mile_run < 0){
782
+        two_mile_run = 0;
783
+    }
784
+
785
+    line[5]->setText(QString::number(sit_ups));
786
+    line[3]->setText(QString::number(push_ups));
787
+    line[4]->setText(QString::number(two_mile_run));
788
+    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
789
+    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
790
+        line[7]->setText("PASS");
791
+    }
792
+    else{
793
+        line[7]->setText("FAIL");
794
+    }
795
+}
796
+
797
+//This one do not sums the points but the quantities of each excercise
798
+
799
+void MainWindow::APFTDelta(){
800
+    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
801
+    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
802
+    double running_time = qFloor((line[2]->text().left(2).append('.'
803
+                                   + line[2]->text().right(2))).toDouble());
804
+    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
805
+
806
+    if (sit_ups > 100){
807
+        sit_ups = 100;
808
+    }
809
+    else if (sit_ups < 0){
810
+        sit_ups = 0;
811
+    }
812
+    if (push_ups > 100){
813
+        push_ups = 100;
814
+    }
815
+    else if (push_ups < 0){
816
+        push_ups = 0;
817
+    }
818
+    if (two_mile_run > 100){
819
+        two_mile_run = 100;
820
+    }
821
+    else if (two_mile_run < 0){
822
+        two_mile_run = 0;
823
+    }
824
+
825
+    int sumaTo = line[0]->text().toInt() + line[1]->text().toInt() + running_time;
826
+    line[3]->setText(QString::number(sit_ups));
827
+    line[4]->setText(QString::number(push_ups));
828
+    line[5]->setText(QString::number(two_mile_run));
829
+    line[6]->setText(QString::number(sumaTo));
830
+    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
831
+        line[7]->setText("PASS");
832
+    }
833
+    else{
834
+        line[7]->setText("FAIL");
835
+    }
836
+}
837
+
838
+
839
+

+ 31
- 0
functions.h View File

@@ -0,0 +1,31 @@
1
+#ifndef FUNCTIONS_H
2
+#define FUNCTIONS_H
3
+
4
+#include <string>
5
+using namespace std;
6
+
7
+bool validateSorts(const QString &a, const QString &b, const QString &c);
8
+void mySortAlpha(QString &a, QString &b, QString &c);
9
+void mySortBeta(QString &a, QString &b, QString &c);
10
+void mySortGamma(QString &a, QString &b, QString &c);
11
+void mySortDelta(QString &a, QString &b, QString &c);
12
+
13
+bool validZuluTime(const QString &time, const QString &zone, int &hours, int &minutes);
14
+QString zuluAlpha(int hours, int minutes, char zone);
15
+QString zuluBeta(int hours, int minutes, char zone);
16
+QString zuluGamma(int hours, int minutes, char zone);
17
+QString zuluDelta(int hours, int minutes, char zone);
18
+
19
+int RPSAlpha(char p1, char p2, int &score1, int &score2);
20
+int RPSBeta(char p1, char p2, int &score1, int &score2);
21
+int RPSGamma(char p1, char p2, int &score1, int &score2);
22
+int RPSDelta(char p1, char p2, int &score1, int &score2);
23
+
24
+void initCheckWMaps();
25
+bool validateCheckQty(QString st, unsigned int &qty);
26
+QString checkWAlpha(int n);
27
+QString checkWBeta(int n);
28
+QString checkWGamma(int n);
29
+QString checkWDelta(int n);
30
+
31
+#endif // FUNCTIONS_H

+ 66
- 0
labTesting.md View File

@@ -0,0 +1,66 @@
1
+# Testing and Unit Testing
2
+
3
+##Objectives
4
+
5
+Throughout this exercise the students will practice:
6
+
7
+* Testing various versions of a program to validate their operation
8
+* Unit Testing
9
+
10
+## Concepts
11
+
12
+As you have learned in previous labs, getting a program to compile is only a minor part of programming. It is super important to test functions in order to validate that they produce the correct results.
13
+
14
+
15
+### Exercise 1
16
+
17
+This exercise is an adaptation of [1]. You are provided with a program that implements several versions of five simple functions, e.g. rock-paper-scisors, sorting 3 numbers. By testing the versions, you and your partner will determine which of the versions is correctly implemented.   
18
+
19
+This exercise requires **NO programming**, just testing. 
20
+
21
+The functions implemented in the program are:
22
+
23
+* **3 Sorts**: a program that receives three strings and sorts them in lexicographical order. For example, given `jirafa`, `zorra`, and `coqui`. Will sort them as: `coqui`, `jirafa`, and `zorra`.
24
+
25
+* **Dice**: when the user presses the `Roll them` button, the program will generate two random numbers between 1 and 6.  The sum of the random numbers is reported. 
26
+
27
+* **Rock, Papers, Scissors**: The user enters the play for the two players ( 'R' for Rock, 'P' for Paper and 'S' for Scissors) and specifies the number of games needed to win the tournament. The program then reports who won and the score. The program reports if a player wins the tournament.
28
+
29
+* **Check Writer**: The user enters a number between 0 and 999,999,999 (inclusive). The program's output is a long string version of the number. For example, if the user inputs '654123' the program will output 'six hundred fifty four thousand one hundred twenty three'.
30
+
31
+* **Zulu time**: given the time in zulu time (Greenwich Mean Time) and the military zone that the user whishes to know, the program outputs the time at that zone. The format for the input is `####` in 23 hour format, e.g. 2212. The list of valid military zones is given in http://en.wikipedia.org/wiki/List_of_military_time_zones. Examples of correct output:
32
+    * Given 1230 and zone A, the output would be 1330
33
+    * Given 1230 and zone N, the output would be 1130
34
+
35
+Step 1: 
36
+Download the program from $XYZ$.
37
+
38
+Step 2:
39
+Run the program. For each of the functions, test all the versions and determine which is the valid one. Report which is the correct version in every method. Also, explain the tests that you performed that allowed you to determine that the other versions are incorrect. 
40
+
41
+
42
+### Exercise 2
43
+
44
+Running tests "by hand" each time that you run a program gets tiresome very quickly. You and your partner have done it for a few simple functions. Imagine doing the same for full-blown program!, such as a browser or word processor.
45
+
46
+Unit tests help programmers produce valid code and ease the process of debugging while avoiding the tedious task of entering tests by hand on each execution.
47
+
48
+
49
+Step 1: 
50
+Download the proyect from $XYZ$. The proyect contains only one source code file `main.cpp`. This file contains four functions whose results are only partially correct. Your task is to write unit tests for each them to identify their wrong results. 
51
+
52
+A unit test function `test_fact()` is provided for the function `fact`. If you invoke this function from `main` and compile and run the program. You will get the following message:
53
+
54
+```cpp
55
+Assertion failed: (fact(2) == 2), function test_fact, file ../UnitTests/main.cpp, line 69.
56
+``` 
57
+
58
+This would be enough for us to claim that function `fact` is not correctly implemented. Comment the invocation of `test_fact()` from main.
59
+
60
+Step 2:
61
+Write unit tests for the rest of the functions. Remember that you must call each of the unit test functions from the `main` for them to run. Copy each of the functions in the provided sheet.
62
+
63
+
64
+### References
65
+
66
+[1] http://nifty.stanford.edu/2005/TestMe/

+ 69
- 0
main.cpp View File

@@ -0,0 +1,69 @@
1
+#include <QApplication>
2
+#include "mainwindow.h"
3
+#include <cstdlib>
4
+#include <ctime>
5
+#include "functions.h"
6
+#include <cassert>
7
+#include <QDebug>
8
+
9
+void testSort() {
10
+    QString a = "AAA" , b = "BBB" , c = "CCC";
11
+    mySortBeta(a,b,c);
12
+    assert( a < b && b < c);
13
+
14
+    a = "AAA", b = "CCC", c = "BBB";
15
+    mySortBeta(a,b,c);
16
+    assert( a < b && b < c);
17
+
18
+    a = "BBB", b = "AAA", c = "CCC";
19
+    mySortBeta(a,b,c);
20
+    assert( a < b && b < c);
21
+
22
+    a = "BBB", b = "CCC", c = "AAA";
23
+    mySortBeta(a,b,c);
24
+    assert( a < b && b < c);
25
+
26
+    a = "CCC", b = "AAA", c = "BBB";
27
+    mySortBeta(a,b,c);
28
+    //qDebug() << a << b << c;
29
+    assert( a < b && b < c);
30
+
31
+    a = "CCC", b = "BBB", c = "AAA";
32
+    mySortBeta(a,b,c);
33
+    assert( a < b && b < c);
34
+
35
+    qDebug() << "Passed Test for Sort!!!!";
36
+}
37
+
38
+void testCheck() {
39
+
40
+    assert( checkWAlpha(91) == QString("ninety one"));
41
+    assert( checkWAlpha(891) == QString("eight hundred ninety one"));
42
+    assert( checkWAlpha(100) == QString("one hundred"));
43
+    assert( checkWAlpha(59123) == QString("fifty nine thousand one hundred twenty three"));
44
+    assert( checkWAlpha(100001) == QString("one hundred thousand one"));
45
+    assert( checkWAlpha(100000) == QString("one hundred thousand"));
46
+    assert( checkWAlpha(100000000) == QString("one hundred million"));
47
+    qDebug() << "Passed Test for Check Word!!!!";
48
+}
49
+
50
+int main(int argc, char *argv[])
51
+{
52
+//    testSort();
53
+    initCheckWMaps(); /*** DONT FORGET ***/
54
+
55
+//    testCheck();
56
+//    qDebug() << checkWAlpha(91);
57
+//    qDebug() << checkWAlpha(891);
58
+//    qDebug() << checkWAlpha(801);
59
+
60
+
61
+    srand(time(NULL));
62
+    QApplication a(argc, argv);
63
+    MainWindow w;
64
+    w.show();
65
+
66
+
67
+
68
+    return a.exec();
69
+}

+ 818
- 0
mainwindow.cpp View File

@@ -0,0 +1,818 @@
1
+#include "mainwindow.h"
2
+#include "ui_mainwindow.h"
3
+#include "secondwindow.cpp"
4
+
5
+#include <QDebug>
6
+#include <QtCore/qmath.h>
7
+#include <QMessageBox>
8
+#include "functions.h"
9
+
10
+MainWindow::MainWindow(QWidget *parent) :
11
+    QMainWindow(parent),
12
+    ui(new Ui::MainWindow)
13
+{
14
+    ui->setupUi(this);
15
+
16
+    //These are the size of the arrays of widgets 'line-edit',
17
+    //'label' and 'button'
18
+    buttonSize = 2;
19
+    lineSize = 7;
20
+    labelSize = 8;
21
+
22
+    // We set every pointer member to point NULL because we
23
+    // when we delete every pointer we dont want to delete a
24
+    // pointer that was already deleted in other moment or
25
+    // was never used
26
+    layout = NULL;
27
+    for (int i = 0; i<buttonSize ; i++){
28
+        button[i] = 0;
29
+    }
30
+    for (int i = 0; i < lineSize ; i++){
31
+        line[i] = 0;
32
+    }
33
+    for (int i = 0; i<labelSize ; i++){
34
+        label[i] = 0;
35
+    }
36
+
37
+    window = new secondwindow;
38
+
39
+    // We need to know whenever the second window is closed to show the
40
+    // main window, or to hide when the second one is showed
41
+    connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
42
+
43
+    if(!dice1.load(":/images/resources/d1.png") || !dice2.load(":/images/resources/d1.png")){
44
+        qDebug() << "Error1 Loading image";
45
+    }
46
+
47
+    initCheckWMaps();
48
+}
49
+
50
+MainWindow::~MainWindow()
51
+{
52
+    delete ui;
53
+}
54
+
55
+//This function show the main window and delete all the items created on the closed one or hide the mainwindow
56
+void MainWindow::mostrar(bool si){
57
+    if (si==true){
58
+        show();
59
+
60
+        // Deleting pointers and point them to NULL
61
+        for (int i = 0; i<buttonSize ; i++){
62
+            delete button[i];
63
+            button[i] = NULL;
64
+        }
65
+        for (int i = 0; i<lineSize ; i++){
66
+            delete line[i];
67
+            line[i] = NULL;
68
+        }
69
+        for (int i = 0; i<labelSize ; i++){
70
+            delete label[i];
71
+            label[i] = NULL;
72
+        }
73
+        delete layout;
74
+        layout = NULL;
75
+        delete window;
76
+
77
+        // Create the new window and connecting it again with the signal
78
+        window = new secondwindow;
79
+        connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
80
+    }
81
+    else hide();
82
+}
83
+
84
+//It is a slot that reads what item of the combo box was selected and save it
85
+//into a member
86
+void MainWindow::whatOption(QString str){
87
+    option = str;
88
+}
89
+
90
+//Clear all the lines that are used
91
+void MainWindow::clearLines(){
92
+    for (int i = 0; i < lineSize; i++){
93
+        if (line[i] != NULL){
94
+            line[i]->clear();
95
+        }
96
+    }
97
+    score1 = score2 = 0;
98
+}
99
+
100
+//It forces the input 1 to be valid
101
+void MainWindow::RPSnormalizer1(QString str){
102
+    //For every character in the string only allow
103
+    //the character 'R' for rock, 'P' for paper and
104
+    //'S' for scissors. Delete all the other characters
105
+    //different from this three, and if is 'r', 'p' or 's'
106
+    //make it uppercase.
107
+    for (int i = 0; i< str.size(); i++){
108
+        if      (str[i] == 'r'){
109
+            str[i] = 'R';
110
+        }
111
+        else if (str[i] == 'p'){
112
+            str[i] = 'P';
113
+        }
114
+        else if (str[i] == 's'){
115
+            str[i] = 'S';
116
+        }
117
+
118
+        else if (str[i] == 'R' || str[i] == 'P' ||
119
+                 str[i] == 'S');//then its ok, do nothing
120
+        else{
121
+            str = str.mid(0,i).append(str.mid(i+1));
122
+        }
123
+    }
124
+
125
+    line[0]->setText(str);
126
+}
127
+
128
+//It forces the input 2 to be valid
129
+void MainWindow::RPSnormalizer2(QString str){
130
+    for (int i = 0; i< str.size(); i++){
131
+        if      (str[i] == 'r'){
132
+            str[i] = 'R';
133
+        }
134
+        else if (str[i] == 'p'){
135
+            str[i] = 'P';
136
+        }
137
+        else if (str[i] == 's'){
138
+            str[i] = 'S';
139
+        }
140
+        else if (str[i] == 'R' || str[i] == 'P' ||
141
+                 str[i] == 'S');//then its ok, do nothing
142
+        else{
143
+            str = str.mid(0,i).append(str.mid(i+1));
144
+        }
145
+    }
146
+
147
+    line[1]->setText(str);
148
+}
149
+
150
+//It forces the input 3 to be valid
151
+void MainWindow::RPSnormalizer3(QString str){
152
+    //Verify that the string do not contains other thing than
153
+    //numbers
154
+    for (int i = 0; i< str.size(); i++){
155
+        if (!str[i].isDigit()){
156
+            str = str.mid(0,i).append(str.mid(i+1));
157
+        }
158
+    }
159
+
160
+    //Left zeros do not count, delete them
161
+    while (str[0] == '0'){
162
+        str = str.mid(1);
163
+    }
164
+
165
+    //If the player exagerates the number of games to win
166
+    //change the string to the maximum number allowed
167
+    if (str.toInt() > 150){
168
+        str = "150";
169
+    }
170
+
171
+    line[2]->setText(str);
172
+}
173
+
174
+//It forces the input to be valid
175
+void MainWindow::CheckWnormalizer(QString str){
176
+    //Just allow numbers
177
+    for (int i = 0; i< str.size(); i++){
178
+        if (!str[i].isDigit()){
179
+            str = str.mid(0,i).append(str.mid(i+1));
180
+        }
181
+    }
182
+
183
+    //Zeros on the left side do not count (delete them)
184
+    while (str[0] == '0'){
185
+        str = str.mid(1);
186
+    }
187
+
188
+    //The maximum is 999,999,999
189
+    if (str.toDouble() > 999999999){
190
+        str = "999999999";
191
+    }
192
+
193
+    line[0]->setText(str);
194
+}
195
+
196
+
197
+
198
+//It forces the first input of Zulu to be valid
199
+void MainWindow::Zulunormalizer1(QString str){
200
+    //Just allow numbers to be written
201
+    for (int i = 0; i< str.size(); i++){
202
+        if (!str[i].isDigit()){
203
+            str = str.mid(0,i).append(str.mid(i+1));
204
+        }
205
+    }
206
+
207
+    //The maximum here is 2359, so force it to be the
208
+    //maximum when the user write a larger number
209
+    if (str.toInt() > 2359){
210
+        str = "2359";
211
+    }
212
+
213
+    line[0]->setText(str);
214
+}
215
+
216
+//It forces the second input of Zulu to be valid
217
+void MainWindow::Zulunormalizer2(QString str){
218
+    //Just allow one character to be written
219
+    if (str.size() > 1){
220
+        str = str[1];
221
+    }
222
+
223
+    //If that only character is 'e', 'c', 'm' or 'p'
224
+    //the uppercase it
225
+    if (str[0] == 'e' || str[0] == 'c' ||
226
+            str[0] == 'm' || str[0] == 'p'){
227
+        str = str[0].toUpper();
228
+    }
229
+    //If we get here is because the character is not
230
+    //the lowercase letters allowed... so if they are
231
+    //not the uppercase letters that we admit we have
232
+    //to delete it.
233
+    else if (str[0] != 'E' || str[0] != 'C' ||
234
+             str[0] != 'M' || str[0] != 'P'){
235
+        str = "";
236
+    }
237
+
238
+    line[1]->setText(str);
239
+}
240
+
241
+//It forces the first input of APFT to be valid
242
+void MainWindow::APFTnormalizer1(QString str){
243
+    //Just admit numbers, delete the other type of
244
+    //characters
245
+    for (int i = 0; i< str.size(); i++){
246
+        if (!str[i].isDigit()){
247
+            str = str.mid(0,i).append(str.mid(i+1));
248
+        }
249
+    }
250
+
251
+    //Left zeros are not valid
252
+    while (str[0] == '0'){
253
+        str = str.mid(1);
254
+    }
255
+
256
+    line[0]->setText(str);
257
+}
258
+
259
+//It forces the second input of APFT to be valid
260
+void MainWindow::APFTnormalizer2(QString str){
261
+    //Just allow the numbers to be written
262
+    for (int i = 0; i< str.size(); i++){
263
+        if (!str[i].isDigit()){
264
+            str = str.mid(0,i).append(str.mid(i+1));
265
+        }
266
+    }
267
+
268
+    //Left-hand zeros? Delete them
269
+    while (str[0] == '0'){
270
+        str = str.mid(1);
271
+    }
272
+
273
+    line[1]->setText(str);
274
+}
275
+
276
+//It forces the third input of APFT to be valid
277
+void MainWindow::APFTnormalizer3(QString str){
278
+    //Allow just numbers on the string only if the
279
+    //character is not in the position 2
280
+    for (int i = 0; i< str.size(); i++){
281
+        if (!str[i].isDigit() && i != 2){
282
+            str = str.mid(0,i).append(str.mid(i+1));
283
+        }
284
+    }
285
+
286
+    //Then if there is a character in the position 2
287
+    //and it is not ':', then add it between the
288
+    //position 1 and 3
289
+    if (str.size() > 2 && str[2] != ':'){
290
+        while (str.size()>2 && !str[2].isDigit()){
291
+            str = str.mid(0,2).append(str.mid(3));
292
+        }
293
+        str = str.mid(0, 2).append(':').append(str.mid(2));
294
+    }
295
+    //If the size exceeds 5, then take the first five
296
+    //so then we will have the format mm:ss
297
+    if (str.size() > 5){
298
+        str = str.mid(0, 5);
299
+    }
300
+
301
+    line[2]->setText(str);
302
+}
303
+
304
+//Checks which version of sort is selected and call it
305
+void MainWindow::sorts(){
306
+    QString a = line[0]->text();
307
+    QString b = line[1]->text();
308
+    QString c = line[2]->text();
309
+
310
+    if (!validateSorts(a,b,c)) {
311
+        QMessageBox::warning(this, "Alert",
312
+             "Please provide the three non-empty strings");
313
+        return;
314
+    }
315
+
316
+    if (option == "Version Alpha"){
317
+        mySortAlpha(a,b,c);
318
+    }
319
+    else if (option == "Version Beta"){
320
+        mySortBeta(a,b,c);
321
+    }
322
+    else if (option == "Version Gamma"){
323
+        mySortGamma(a,b,c);
324
+    }
325
+    else{
326
+        mySortDelta(a,b,c);
327
+    }
328
+    line[3]->setText(a);
329
+    line[4]->setText(b);
330
+    line[5]->setText(c);
331
+}
332
+
333
+
334
+
335
+
336
+//Checks which version of RPS is selected and call it
337
+void MainWindow::RPSs(){
338
+
339
+    QString p1 = line[0]->text();
340
+    QString p2 = line[1]->text();
341
+    QString gamesToWin = line[2]->text();
342
+
343
+    if (p1.length() * p2.length() * gamesToWin.length() == 0) {
344
+        QMessageBox::warning(this, "Alert",
345
+                             "Please provide a play for both players and the number of games to win");
346
+        return;
347
+    }
348
+
349
+    int winnerNum;
350
+    if (option == "Version Alpha")
351
+        winnerNum = RPSAlpha(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
352
+    else if (option == "Version Beta")
353
+        winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
354
+    else if (option == "Version Gamma")
355
+        winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
356
+    else
357
+        winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
358
+
359
+    QString st;
360
+
361
+    switch(winnerNum) {
362
+    case 1:  st = "Player 1"; break;
363
+    case 2:  st = "Player 2"; break;
364
+    case 0:  st = "Tie"; break;
365
+    default: st = "Error";
366
+    }
367
+
368
+    line[3]->setText(st);
369
+
370
+    line[4]->setText(QString::number(score1) + " to " + QString::number(score2));
371
+
372
+    if (score1 == gamesToWin.toInt() || score2 == gamesToWin.toInt() ) {
373
+        QMessageBox::warning(this, "Alert",
374
+                             "Game won by " + st + "!!!");
375
+        score1 = score2 = 0;
376
+    }
377
+
378
+}
379
+
380
+//Checks which version of dice is selected and call it
381
+void MainWindow::dices(){
382
+    if (option == "Version Alpha")
383
+        diceAlpha();
384
+    else if (option == "Version Beta")
385
+        diceBeta();
386
+    else if (option == "Version Gamma")
387
+        diceGamma();
388
+    else
389
+        diceDelta();
390
+}
391
+
392
+
393
+//Checks which version of check-writer is selected and call it
394
+void MainWindow::checkWs(){
395
+    unsigned int qty;
396
+    if (!validateCheckQty(line[0]->text(),qty)) {
397
+        QMessageBox::warning(this, "Alert",
398
+                             "Enter a valid amount!");
399
+    }
400
+
401
+    if (option == "Version Alpha")
402
+        line[1]->setText( checkWAlpha(qty) );
403
+    else if (option == "Version Beta")
404
+        line[1]->setText( checkWBeta(qty) );
405
+    else if (option == "Version Gamma")
406
+        line[1]->setText( checkWGamma(qty) );
407
+    else
408
+        line[1]->setText( checkWDelta(qty) );
409
+}
410
+
411
+//Checks which version of zulu is selected and call it
412
+void MainWindow::zulus(){
413
+    QString zuluTime = line[0]->text();
414
+    QString zuluZone = line[1]->text();
415
+    int hours, minutes;
416
+
417
+    if (!validZuluTime(zuluTime, zuluZone, hours, minutes) ) {
418
+
419
+        QMessageBox::warning(this, "Alert",
420
+                             "Either Zulu Time or Zone is not valid");
421
+        line[2]->setText("Error");
422
+        return;
423
+    }
424
+    if (option == "Version Alpha")
425
+        line[2]->setText( zuluAlpha(hours, minutes, zuluZone.toStdString()[0]) );
426
+    else if (option == "Version Beta")
427
+        line[2]->setText( zuluBeta(hours, minutes, zuluZone.toStdString()[0]) );
428
+    else if (option == "Version Gamma")
429
+        line[2]->setText( zuluGamma(hours, minutes, zuluZone.toStdString()[0]) );
430
+    else
431
+        line[2]->setText( zuluDelta(hours, minutes, zuluZone.toStdString()[0]) );
432
+
433
+}
434
+
435
+//Checks which version of APFT is selected and call it
436
+void MainWindow::APFTs(){
437
+    if (option == "Version Alpha"){
438
+        APFTAlpha();
439
+    }
440
+    else if (option == "Version Beta"){
441
+        APFTBeta();
442
+    }
443
+    else if (option == "Version Gamma"){
444
+        APFTGamma();
445
+    }
446
+    else{
447
+        APFTDelta();
448
+    }
449
+}
450
+
451
+//Here is what happend when Sort-button is clicked
452
+void MainWindow::on_SortsButton_clicked()
453
+{
454
+    //Create a new QComboBox and add the items in it
455
+    method = new QComboBox;
456
+    method->addItem("Version Alpha");
457
+    method->addItem("Version Beta");
458
+    method->addItem("Version Gamma");
459
+    method->addItem("Version Delta");
460
+    option = "Version Alpha"; //Default option is alpha
461
+
462
+    //We create a new layout and insert the comboBox to it
463
+    layout = new QGridLayout;
464
+    layout->addWidget(method, 0, 0, 1, -1);
465
+
466
+    //The buttons needed are sort and clear so we create them
467
+    button[0] = new QPushButton("Sort");
468
+    button[1] = new QPushButton("Clear");
469
+
470
+    //3 lines for input and 3 for output
471
+    for (int i = 0; i<6 ; i++){
472
+        line[i] = new QLineEdit;
473
+    }
474
+
475
+    //The user is not able to write on the output lines
476
+    line[3]->setEnabled(false);
477
+    line[4]->setEnabled(false);
478
+    line[5]->setEnabled(false);
479
+
480
+    //Labels to let the user understand the app
481
+    label[0] = new QLabel("Input");
482
+    label[1] = new QLabel("Output");
483
+
484
+    //Here we insert the widgets on the layout
485
+    layout->addWidget(label[0], 1, 0);
486
+    layout->addWidget(label[1], 1, 2);
487
+    layout->addWidget(line[0], 2, 0);
488
+    layout->addWidget(line[1], 3, 0);
489
+    layout->addWidget(line[2], 4, 0);
490
+    layout->addWidget(button[0], 1, 1, 2, 1);
491
+    layout->addWidget(button[1], 3, 1, 2, 1);
492
+    layout->addWidget(line[3], 2, 2);
493
+    layout->addWidget(line[4], 3, 2);
494
+    layout->addWidget(line[5], 4, 2);
495
+
496
+    //Here we connect the signals of the widgets generated
497
+    //by code to their respective functions
498
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
499
+    connect(button[0], SIGNAL(clicked()), this, SLOT(sorts()));
500
+    connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
501
+
502
+    //Now that we have set our new window, we hide the main-window
503
+    //and show the new one. The new-window has a signal that
504
+    //notify when it was closed so we can shor the main-window
505
+    window->setLayout(layout);
506
+    mostrar(false);
507
+    window->show();
508
+}
509
+
510
+//Here is what happend when Dice-button is clicked
511
+void MainWindow::on_DiceButton_clicked()
512
+{
513
+    //Create a new QComboBox and add the items in it
514
+    method = new QComboBox;
515
+    method->addItem("Version Alpha");
516
+    method->addItem("Version Beta");
517
+    method->addItem("Version Gamma");
518
+    method->addItem("Version Delta");
519
+    option = "Version Alpha"; //Default option is alpha
520
+
521
+    //We create a new layout and insert the comboBox to it
522
+    layout = new QGridLayout;
523
+    layout->addWidget(method, 0, 0, 1, -1);
524
+
525
+    //Labels to let the user understand the app
526
+    label[0] = new QLabel("Dice 1");
527
+    label[1] = new QLabel("Dice 2");
528
+    label[2] = new QLabel("Total");
529
+
530
+    //The user is not able to write on the output line
531
+    line[0] = new QLineEdit;
532
+    line[0]->setEnabled(false);
533
+
534
+    //Here we just need one button to roll the dices
535
+    button[0] = new QPushButton("Roll them!");
536
+
537
+    //Labels to put the dices' images on them
538
+    label[3] = new QLabel;
539
+    label[4] = new QLabel;
540
+    label[3]->setPixmap(QPixmap::fromImage(dice1));
541
+    label[4]->setPixmap(QPixmap::fromImage(dice2));
542
+
543
+    //Here we insert the widgets on the layout
544
+    layout->addWidget(label[0], 1, 0);
545
+    layout->addWidget(label[3], 1, 1);
546
+    layout->addWidget(label[1], 2, 0);
547
+    layout->addWidget(label[4], 2, 1);
548
+    layout->addWidget(label[2], 3, 0);
549
+    layout->addWidget(line[0], 3, 1);
550
+    layout->addWidget(button[0], 1, 2, 2, 1);
551
+
552
+    //Here we connect the signals of the widgets generated
553
+    //by code to their respective functions
554
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
555
+    connect(button[0], SIGNAL(clicked()), this, SLOT(dices()));
556
+
557
+    //Now that we have set our new window, we hide the main-window
558
+    //and show the new one. The new-window has a signal that
559
+    //notify when it was closed so we can shor the main-window
560
+    window->setLayout(layout);
561
+    mostrar(false);
562
+    window->show();
563
+}
564
+
565
+//Here is what happend when RPS-button is clicked
566
+void MainWindow::on_RPSButton_clicked()
567
+{
568
+    //Create a new QComboBox and add the items in it
569
+    method = new QComboBox;
570
+    method->addItem("Version Alpha");
571
+    method->addItem("Version Beta");
572
+    method->addItem("Version Gamma");
573
+    method->addItem("Version Delta");
574
+    option = "Version Alpha"; //Default option is alpha
575
+
576
+    //We create a new layout and insert the comboBox to it
577
+    layout = new QGridLayout;
578
+    layout->addWidget(method, 0, 0, 1, -1);
579
+
580
+    //The buttons needed here are the 'play' and 'clear' buttons
581
+    button[0] = new QPushButton("Play");
582
+    button[1] = new QPushButton("Clear");
583
+
584
+    //3 inputs and 1 output
585
+    for (int i = 0; i<4; i++){
586
+        line[i] = new QLineEdit;
587
+    }
588
+
589
+    //The user is not able to write on the output line
590
+    line[3]->setEnabled(false);
591
+
592
+    //Labels to let the user understand the app
593
+    label[0] = new QLabel("Player 1's moves");
594
+    label[1] = new QLabel("Player 2's moves");
595
+    label[2] = new QLabel("How many games to win:");
596
+    label[3] = new QLabel("Winner:");
597
+    label[4] = new QLabel("Tournament:");
598
+    //lines for score
599
+    line[4] = new QLineEdit;
600
+    line[4]->setEnabled(false);
601
+
602
+    //Here we insert the widgets on the layout
603
+    layout->addWidget(label[0], 1, 0);
604
+    layout->addWidget(line[0], 2, 0);
605
+    layout->addWidget(label[1], 3, 0);
606
+    layout->addWidget(line[1], 4, 0);
607
+    layout->addWidget(label[2], 5, 0);
608
+    layout->addWidget(line[2], 5, 1);
609
+    layout->addWidget(label[3], 6, 0);
610
+    layout->addWidget(line[3], 6, 1);
611
+    layout->addWidget(button[0], 2, 1);
612
+    layout->addWidget(button[1], 3, 1);
613
+    layout->addWidget(line[4],7 ,1 );
614
+    layout->addWidget(label[4],7 ,0 );
615
+
616
+    //Here we connect the signals of the widgets generated
617
+    //by code to their respective functions
618
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
619
+    connect(button[0], SIGNAL(clicked()), this, SLOT(RPSs()));
620
+    connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
621
+    connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer1(QString)));
622
+    connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer2(QString)));
623
+    connect(line[2], SIGNAL(textEdited(QString)), this, SLOT(RPSnormalizer3(QString)));
624
+
625
+    //Now that we have set our new window, we hide the main-window
626
+    //and show the new one. The new-window has a signal that
627
+    //notify when it was closed so we can shor the main-window
628
+    window->setLayout(layout);
629
+    mostrar(false);
630
+    window->show();
631
+    score1 = score2 = 0;
632
+}
633
+
634
+//Here is what happend when CheckWritter-button is clicked
635
+void MainWindow::on_CheckWriterButton_clicked()
636
+{
637
+    //Create a new QComboBox and add the items in it
638
+    method = new QComboBox;
639
+    method->addItem("Version Alpha");
640
+    method->addItem("Version Beta");
641
+    method->addItem("Version Gamma");
642
+    method->addItem("Version Delta");
643
+    option = "Version Alpha"; //Default option is alpha
644
+
645
+    //We create a new layout and insert the comboBox to it
646
+    layout = new QGridLayout;
647
+    layout->addWidget(method, 0, 0, 1, -1);
648
+
649
+    //Label to let the user understand the app
650
+    label[0] = new QLabel("Number to convert");
651
+
652
+    //We just need two buttons to clear or convert
653
+    button[0] = new QPushButton("Convert");
654
+    button[1] = new QPushButton("Clear");
655
+
656
+    //1 output and 1 input
657
+    for (int i = 0; i<2; i++){
658
+        line[i] = new QLineEdit;
659
+    }
660
+
661
+    //The user is not able to write on the output line
662
+    line[1]->setEnabled(false);
663
+
664
+    //Here we insert the widgets on the layout
665
+    layout->addWidget(label[0], 1, 0, 1, 2);
666
+    layout->addWidget(line[0], 2, 0, 1, 2);
667
+    layout->addWidget(button[0], 3, 0);
668
+    layout->addWidget(button[1], 3, 1);
669
+    layout->addWidget(line[1], 4, 0, 1, 2);
670
+
671
+    //Here we connect the signals of the widgets generated
672
+    //by code to their respective functions
673
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
674
+    connect(button[0], SIGNAL(clicked()), this, SLOT(checkWs()));
675
+    connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
676
+    //connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(CheckWnormalizer(QString)));
677
+
678
+    //Now that we have set our new window, we hide the main-window
679
+    //and show the new one. The new-window has a signal that
680
+    //notify when it was closed so we can shor the main-window
681
+    window->setLayout(layout);
682
+    mostrar(false);
683
+    window->show();
684
+}
685
+
686
+//Here is what happend when Zulu-button is clicked
687
+void MainWindow::on_ZuluButton_clicked()
688
+{
689
+    //Create a new QComboBox and add the items in it
690
+    method = new QComboBox;
691
+    method->addItem("Version Alpha");
692
+    method->addItem("Version Beta");
693
+    method->addItem("Version Gamma");
694
+    method->addItem("Version Delta");
695
+    option = "Version Alpha"; //Default option is alpha
696
+
697
+    //We create a new layout and insert the comboBox to it
698
+    layout = new QGridLayout;
699
+    layout->addWidget(method, 0, 0, 1, -1);
700
+
701
+    //Labels to let the user understand the app
702
+    label[0] = new QLabel("Zulu time:");
703
+    label[1] = new QLabel("Standard time");
704
+
705
+    //Just the buttons to clear and convert the time
706
+    button[0] = new QPushButton("Clear");
707
+    button[1] = new QPushButton("Convert");
708
+
709
+    //2 inputs and 1 output
710
+    for (int i = 0; i<3; i++){
711
+        line[i] = new QLineEdit;
712
+    }
713
+
714
+    //The user is not able to write on the output line
715
+    line[2]->setEnabled(false);
716
+
717
+    //Here we insert the widgets on the layout
718
+    layout->addWidget(label[0], 1, 0);
719
+    layout->addWidget(line[0], 2, 0);
720
+    layout->addWidget(line[1], 2, 1);
721
+    layout->addWidget(button[0], 3, 0);
722
+    layout->addWidget(button[1], 3, 1);
723
+    layout->addWidget(label[1], 4, 0);
724
+    layout->addWidget(line[2], 4, 1);
725
+
726
+    //Here we connect the signals of the widgets generated
727
+    //by code to their respective functions
728
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
729
+    connect(button[0], SIGNAL(clicked()), this, SLOT(clearLines()));
730
+    connect(button[1], SIGNAL(clicked()), this, SLOT(zulus()));
731
+
732
+    // Rafa 2014-09-16 - Validation will be done when button is clicked
733
+    //    connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer1(QString)));
734
+    //    connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer2(QString)));
735
+
736
+    //Now that we have set our new window, we hide the main-window
737
+    //and show the new one. The new-window has a signal that
738
+    //notify when it was closed so we can shor the main-window
739
+    window->setLayout(layout);
740
+    mostrar(false);
741
+    window->show();
742
+}
743
+
744
+//Here is what happend when APFT-button is clicked
745
+void MainWindow::on_APFTButton_clicked()
746
+{
747
+    //Create a new QComboBox and add the items in it
748
+    method = new QComboBox;
749
+    method->addItem("Version Alpha");
750
+    method->addItem("Version Beta");
751
+    method->addItem("Version Gamma");
752
+    method->addItem("Version Delta");
753
+    option = "Version Alpha"; //Default option is alpha
754
+
755
+    //We create a new layout and insert the comboBox to it
756
+    layout = new QGridLayout;
757
+    layout->addWidget(method, 0, 0, 1, -1);
758
+
759
+    //3 inputs and 4 outputs
760
+    for (int i = 0; i<7; i++){
761
+        line[i] = new QLineEdit;
762
+    }
763
+
764
+    //The user is not able to write on the output lines
765
+    line[3]->setEnabled(false);
766
+    line[4]->setEnabled(false);
767
+    line[5]->setEnabled(false);
768
+    line[6]->setEnabled(false);
769
+
770
+    //Labels to let the user understand the app
771
+    label[0] = new QLabel("Sit-Ups");
772
+    label[1] = new QLabel("Push-Ups");
773
+    label[2] = new QLabel("2 Mile Run");
774
+    label[3] = new QLabel("Sit-Ups Score");
775
+    label[4] = new QLabel("Push-Ups Score");
776
+    label[5] = new QLabel("2 Mile Run Score");
777
+    label[6] = new QLabel("Total Score");
778
+    label[7] = new QLabel("----");
779
+
780
+    //Just the buttons to calculate it and clear the lines
781
+    button[0] = new QPushButton("Calculate");
782
+    button[1] = new QPushButton("Clear");
783
+
784
+    //Here we insert the widgets on the layout
785
+    layout->addWidget(label[0], 1, 0);
786
+    layout->addWidget(label[1], 2, 0);
787
+    layout->addWidget(label[2], 3, 0);
788
+    layout->addWidget(button[0], 4, 0);
789
+    layout->addWidget(line[0], 1, 1);
790
+    layout->addWidget(line[1], 2, 1);
791
+    layout->addWidget(line[2], 3, 1);
792
+    layout->addWidget(button[1], 4, 1);
793
+    layout->addWidget(label[3], 1, 2);
794
+    layout->addWidget(label[4], 2, 2);
795
+    layout->addWidget(label[5], 3, 2);
796
+    layout->addWidget(label[6], 4, 2);
797
+    layout->addWidget(line[3], 1, 3);
798
+    layout->addWidget(line[4], 2, 3);
799
+    layout->addWidget(line[5], 3, 3);
800
+    layout->addWidget(line[6], 4, 3);
801
+    layout->addWidget(label[7], 4, 4);
802
+
803
+    //Here we connect the signals of the widgets generated
804
+    //by code to their respective functions
805
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
806
+    connect(button[0], SIGNAL(clicked()), this, SLOT(APFTs()));
807
+    connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
808
+    connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer1(QString)));
809
+    connect(line[1], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer2(QString)));
810
+    connect(line[2], SIGNAL(textEdited(QString)), this, SLOT(APFTnormalizer3(QString)));
811
+
812
+    //Now that we have set our new window, we hide the main-window
813
+    //and show the new one. The new-window has a signal that
814
+    //notify when it was closed so we can shor the main-window
815
+    window->setLayout(layout);
816
+    mostrar(false);
817
+    window->show();
818
+}

+ 99
- 0
mainwindow.h View File

@@ -0,0 +1,99 @@
1
+#ifndef MAINWINDOW_H
2
+#define MAINWINDOW_H
3
+
4
+#include <QMainWindow>
5
+#include <QtGui>
6
+#include "secondwindow.h"
7
+
8
+#include <QGridLayout>
9
+#include <QPushButton>
10
+#include <QLineEdit>
11
+#include <QLabel>
12
+#include <QComboBox>
13
+#include <QString>
14
+#include <QImage>
15
+
16
+namespace Ui {
17
+    class MainWindow;
18
+}
19
+
20
+class MainWindow : public QMainWindow
21
+{
22
+    Q_OBJECT
23
+
24
+public:
25
+    explicit MainWindow(QWidget *parent = 0);
26
+    ~MainWindow();
27
+
28
+    void diceAlpha();
29
+    void diceBeta();
30
+    void diceGamma();
31
+    void diceDelta();
32
+
33
+    void APFTAlpha();
34
+    void APFTBeta();
35
+    void APFTGamma();
36
+    void APFTDelta();
37
+
38
+private slots:
39
+    void on_SortsButton_clicked();
40
+    void on_DiceButton_clicked();
41
+    void on_RPSButton_clicked();
42
+    void on_CheckWriterButton_clicked();
43
+    void on_ZuluButton_clicked();
44
+    void on_APFTButton_clicked();
45
+
46
+    void mostrar(bool si);
47
+
48
+    void whatOption(QString str);
49
+
50
+    void clearLines();
51
+
52
+    void RPSnormalizer1(QString str);
53
+
54
+    void RPSnormalizer2(QString str);
55
+
56
+    void RPSnormalizer3(QString str);
57
+
58
+    void CheckWnormalizer(QString str);
59
+
60
+    void Zulunormalizer1(QString str);
61
+
62
+    void Zulunormalizer2(QString str);
63
+
64
+    void APFTnormalizer1(QString str);
65
+
66
+    void APFTnormalizer2(QString str);
67
+
68
+    void APFTnormalizer3(QString str);
69
+
70
+    void sorts();
71
+
72
+    void RPSs();
73
+
74
+    void dices();
75
+
76
+    void checkWs();
77
+
78
+    void zulus();
79
+
80
+    void APFTs();
81
+
82
+private:
83
+    Ui::MainWindow *ui;
84
+    secondwindow *window;
85
+    QGridLayout *layout;
86
+    QPushButton *button[2];
87
+    int buttonSize;
88
+    QLineEdit *line[7];
89
+    int lineSize;
90
+    QLabel *label[7];
91
+    int labelSize;
92
+    QComboBox *method;
93
+    QString option;
94
+    QImage dice1;
95
+    QImage dice2;
96
+    int score1, score2;
97
+};
98
+
99
+#endif // MAINWINDOW_H

+ 193
- 0
mainwindow.ui View File

@@ -0,0 +1,193 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<ui version="4.0">
3
+ <class>MainWindow</class>
4
+ <widget class="QMainWindow" name="MainWindow">
5
+  <property name="geometry">
6
+   <rect>
7
+    <x>0</x>
8
+    <y>0</y>
9
+    <width>487</width>
10
+    <height>257</height>
11
+   </rect>
12
+  </property>
13
+  <property name="sizePolicy">
14
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
15
+    <horstretch>0</horstretch>
16
+    <verstretch>0</verstretch>
17
+   </sizepolicy>
18
+  </property>
19
+  <property name="minimumSize">
20
+   <size>
21
+    <width>361</width>
22
+    <height>202</height>
23
+   </size>
24
+  </property>
25
+  <property name="windowTitle">
26
+   <string>MainWindow</string>
27
+  </property>
28
+  <widget class="QWidget" name="centralWidget">
29
+   <widget class="QPushButton" name="SortsButton">
30
+    <property name="geometry">
31
+     <rect>
32
+      <x>10</x>
33
+      <y>70</y>
34
+      <width>141</width>
35
+      <height>61</height>
36
+     </rect>
37
+    </property>
38
+    <property name="text">
39
+     <string>3 Sorts</string>
40
+    </property>
41
+   </widget>
42
+   <widget class="QPushButton" name="RPSButton">
43
+    <property name="geometry">
44
+     <rect>
45
+      <x>330</x>
46
+      <y>70</y>
47
+      <width>141</width>
48
+      <height>61</height>
49
+     </rect>
50
+    </property>
51
+    <property name="text">
52
+     <string>Rock, Paper, 
53
+ Scissors</string>
54
+    </property>
55
+   </widget>
56
+   <widget class="QPushButton" name="DiceButton">
57
+    <property name="geometry">
58
+     <rect>
59
+      <x>170</x>
60
+      <y>70</y>
61
+      <width>141</width>
62
+      <height>61</height>
63
+     </rect>
64
+    </property>
65
+    <property name="text">
66
+     <string>Dice</string>
67
+    </property>
68
+   </widget>
69
+   <widget class="QPushButton" name="APFTButton">
70
+    <property name="geometry">
71
+     <rect>
72
+      <x>330</x>
73
+      <y>140</y>
74
+      <width>141</width>
75
+      <height>61</height>
76
+     </rect>
77
+    </property>
78
+    <property name="text">
79
+     <string>APFT</string>
80
+    </property>
81
+   </widget>
82
+   <widget class="QPushButton" name="ZuluButton">
83
+    <property name="geometry">
84
+     <rect>
85
+      <x>170</x>
86
+      <y>140</y>
87
+      <width>141</width>
88
+      <height>61</height>
89
+     </rect>
90
+    </property>
91
+    <property name="text">
92
+     <string>Zulu</string>
93
+    </property>
94
+   </widget>
95
+   <widget class="QPushButton" name="CheckWriterButton">
96
+    <property name="geometry">
97
+     <rect>
98
+      <x>10</x>
99
+      <y>140</y>
100
+      <width>141</width>
101
+      <height>61</height>
102
+     </rect>
103
+    </property>
104
+    <property name="text">
105
+     <string>Check Writer</string>
106
+    </property>
107
+   </widget>
108
+   <widget class="QFrame" name="frame">
109
+    <property name="geometry">
110
+     <rect>
111
+      <x>-30</x>
112
+      <y>0</y>
113
+      <width>581</width>
114
+      <height>61</height>
115
+     </rect>
116
+    </property>
117
+    <property name="styleSheet">
118
+     <string notr="true">background-color: gray;</string>
119
+    </property>
120
+    <property name="frameShape">
121
+     <enum>QFrame::StyledPanel</enum>
122
+    </property>
123
+    <property name="frameShadow">
124
+     <enum>QFrame::Raised</enum>
125
+    </property>
126
+    <widget class="QLabel" name="label">
127
+     <property name="geometry">
128
+      <rect>
129
+       <x>180</x>
130
+       <y>10</y>
131
+       <width>161</width>
132
+       <height>41</height>
133
+      </rect>
134
+     </property>
135
+     <property name="font">
136
+      <font>
137
+       <pointsize>23</pointsize>
138
+      </font>
139
+     </property>
140
+     <property name="styleSheet">
141
+      <string notr="true">color:white;</string>
142
+     </property>
143
+     <property name="text">
144
+      <string>Testing Lab</string>
145
+     </property>
146
+    </widget>
147
+    <widget class="QFrame" name="frame_2">
148
+     <property name="geometry">
149
+      <rect>
150
+       <x>30</x>
151
+       <y>54</y>
152
+       <width>641</width>
153
+       <height>4</height>
154
+      </rect>
155
+     </property>
156
+     <property name="styleSheet">
157
+      <string notr="true">background-color:red</string>
158
+     </property>
159
+     <property name="frameShape">
160
+      <enum>QFrame::StyledPanel</enum>
161
+     </property>
162
+     <property name="frameShadow">
163
+      <enum>QFrame::Raised</enum>
164
+     </property>
165
+    </widget>
166
+   </widget>
167
+   <widget class="QFrame" name="frame_3">
168
+    <property name="geometry">
169
+     <rect>
170
+      <x>290</x>
171
+      <y>200</y>
172
+      <width>201</width>
173
+      <height>61</height>
174
+     </rect>
175
+    </property>
176
+    <property name="styleSheet">
177
+     <string notr="true">background-image: url(/home/rgb/Desktop/eip/CaesarCipher/logo.png);
178
+border: 0px;
179
+repeat: no-repeat;</string>
180
+    </property>
181
+    <property name="frameShape">
182
+     <enum>QFrame::StyledPanel</enum>
183
+    </property>
184
+    <property name="frameShadow">
185
+     <enum>QFrame::Raised</enum>
186
+    </property>
187
+   </widget>
188
+  </widget>
189
+ </widget>
190
+ <layoutdefault spacing="6" margin="11"/>
191
+ <resources/>
192
+ <connections/>
193
+</ui>

+ 11
- 0
secondwindow.cpp View File

@@ -0,0 +1,11 @@
1
+#include "secondwindow.h"
2
+
3
+secondwindow::secondwindow(QWidget *parent) :
4
+    QWidget(parent)
5
+{
6
+
7
+}
8
+
9
+void secondwindow::closeEvent(QCloseEvent *){
10
+    emit cerrado(true);
11
+}

+ 22
- 0
secondwindow.h View File

@@ -0,0 +1,22 @@
1
+#ifndef SECONDWINDOW_H
2
+#define SECONDWINDOW_H
3
+
4
+#include <QWidget>
5
+
6
+class secondwindow : public QWidget
7
+{
8
+    Q_OBJECT
9
+public:
10
+    explicit secondwindow(QWidget *parent = 0);
11
+
12
+signals:
13
+    void cerrado(bool si);
14
+
15
+protected:
16
+    virtual void closeEvent(QCloseEvent *);
17
+
18
+public slots:
19
+
20
+};
21
+
22
+#endif // SECONDWINDOW_H