소스 검색

Merged the version from lab07 into this one. Commented in Spanish and English. Removed (most of) the dead functions.

부모
커밋
da280eec82
9개의 변경된 파일684개의 추가작업 그리고 1091개의 파일을 삭제
  1. 1
    0
      Testing.pro
  2. 60
    511
      functions.cpp
  3. 296
    8
      functions.h
  4. 1
    49
      main.cpp
  5. 126
    439
      mainwindow.cpp
  6. 160
    45
      mainwindow.h
  7. 13
    37
      mainwindow.ui
  8. 1
    1
      secondwindow.cpp
  9. 26
    1
      secondwindow.h

+ 1
- 0
Testing.pro 파일 보기

@@ -25,3 +25,4 @@ FORMS    += mainwindow.ui
25 25
 
26 26
 RESOURCES += \
27 27
     images.qrc
28
+

+ 60
- 511
functions.cpp 파일 보기

@@ -1,3 +1,5 @@
1
+// RAN - 2015-06-26 - Fixed the issue with the leading zeros in Zulu
2
+
1 3
 #include "mainwindow.h"
2 4
 #include "ui_mainwindow.h"
3 5
 
@@ -14,6 +16,7 @@
14 16
 #include <unistd.h>
15 17
 #endif
16 18
 
19
+
17 20
 // =========================================================
18 21
 // Sort Functions
19 22
 // =========================================================
@@ -108,362 +111,97 @@ void mySortDelta(QString &a, QString &b, QString &c) {
108 111
 }
109 112
 
110 113
 
111
-//This is the correct dice roller
112
-void MainWindow::diceAlpha(){
113
-    QString a, b;
114
-
115
-    //This loop is used to simulate the dice rolling by
116
-    //changing the images at a slowing down speed
117
-    for (int i = 0; i<=150000 ; i=i+5000){
118
-
119
-#ifdef _WIN32
120
-        Sleep(i);
121
-#else
122
-        usleep(i);
123
-#endif
124
-
125
-        //First dice image. Since we want random pictures
126
-        //on each iteration, we get a random number, converted
127
-        //it to string and append it to others string that
128
-        //conform the names of the dices
129
-        a = ":/images/resources/d";
130
-        a.append(QString::number(rand()%6 + 1));
131
-        a.append(".png");
132
-
133
-        b = ":/images/resources/d";
134
-        b.append(QString::number(rand()%6 + 1));
135
-        b.append(".png");
136
-
137
-        //We load the images and check if there is no problem with them
138
-        if(!dice1.load(a) || !dice2.load(b)){
139
-            qDebug() << "Error2 Loading image";
140
-        }
141
-
142
-        //Finally we set the labels with the random dice images
143
-        label[3]->setPixmap(QPixmap::fromImage(dice1));
144
-        label[4]->setPixmap(QPixmap::fromImage(dice2));
145
-
146
-// Is there an option to see the changes of the dice/label
147
-// in this function and no just when we get out of it?
148
-
149
-//        Fail attempts
150
-//        layout->update();
151
-//        repaint();
152
-//        window->repaint();
153
-
154
-//        label[3]->repaint();
155
-//        label[3]->update();
156
-//        label[3]->hide();
157
-//        label[3]->show();
158
-//        label[3]->setVisible(false);
159
-//        label[3]->setVisible(true);
160
-
161
-//        layout->update();
162
-//        update();
163
-//        window->update();
164
-
165
-        window->hide();
166
-        window->show();
167
-    }
168
-
169
-    //Finally, we set the result of the sum of the dices.
170
-    QString a2 = (QString)a[20];
171
-    QString b2 = (QString)b[20];
172
-    int total = a2.toInt() + b2.toInt();
173
-    line[0]->setText(QString::number(total));
174
-}
175
-
176
-//This version sums the first dice twice
177
-void MainWindow::diceBeta(){
178
-    QString a, b;
179
-
180
-    for (int i = 0; i<=150000 ; i=i+5000){
181
-#ifdef _WIN32
182
-        Sleep(i);
183
-#else
184
-        usleep(i);
185
-#endif
186
-        a = ":/images/resources/d";
187
-        a.append(QString::number(rand()%6 + 1));
188
-        a.append(".png");
189
-
190
-        b = ":/images/resources/d";
191
-        b.append(QString::number(rand()%6 + 1));
192
-        b.append(".png");
193
-
194
-        if(!dice1.load(a) || !dice2.load(b)){
195
-            qDebug() << "Error2 Loading image";
196
-        }
197
-
198
-        label[3]->setPixmap(QPixmap::fromImage(dice1));
199
-        label[4]->setPixmap(QPixmap::fromImage(dice2));
200
-
201
-// Is there an option to see the changes of the dice/label
202
-// in this function and no just when we get out of it?
203
-        window->hide();
204
-        window->show();
205
-    }
206
-
207
-    int total = a[20].digitValue() + a[20].digitValue();
208
-    line[0]->setText(QString::number(total));
209
-}
210
-
211
-//This one substracts the second dice to the first one
212
-void MainWindow::diceGamma(){
213
-    QString a, b;
214
-
215
-    for (int i = 0; i<=150000 ; i=i+5000){
216
-#ifdef _WIN32
217
-        Sleep(i);
218
-#else
219
-        usleep(i);
220
-#endif
221
-        a = ":/images/resources/d";
222
-        a.append(QString::number(rand()%6 + 1));
223
-        a.append(".png");
224
-
225
-        b = ":/images/resources/d";
226
-        b.append(QString::number(rand()%6 + 1));
227
-        b.append(".png");
228
-
229
-        if(!dice1.load(a) || !dice2.load(b)){
230
-            qDebug() << "Error2 Loading image";
231
-        }
232
-
233
-        label[3]->setPixmap(QPixmap::fromImage(dice1));
234
-        label[4]->setPixmap(QPixmap::fromImage(dice2));
235
-
236
-// Is there an option to see the changes of the dice/label
237
-// in this function and no just when we get out of it?
238
-        window->hide();
239
-        window->show();
240
-    }
241
-
242
-    QString a2 = (QString)a[20];
243
-    QString b2 = (QString)b[20];
244
-    int total = a2.toInt() - b2.toInt();
245
-    line[0]->setText(QString::number(total));
246
-}
247
-
248
-//This one tooks the number 6 as a 12
249
-void MainWindow::diceDelta(){
250
-    QString a, b;
251
-
252
-    for (int i = 0; i<=150000 ; i=i+5000){
253
-#ifdef _WIN32
254
-        Sleep(i);
255
-#else
256
-        usleep(i);
257
-#endif
258
-        a = ":/images/resources/d";
259
-        a.append(QString::number(rand()%6 + 1));
260
-        a.append(".png");
261
-
262
-        b = ":/images/resources/d";
263
-        b.append(QString::number(rand()%6 + 1));
264
-        b.append(".png");
265 114
 
266
-        if(!dice1.load(a) || !dice2.load(b)){
267
-            qDebug() << "Error2 Loading image";
268
-        }
269
-
270
-        label[3]->setPixmap(QPixmap::fromImage(dice1));
271
-        label[4]->setPixmap(QPixmap::fromImage(dice2));
272
-
273
-// Is there an option to see the changes of the dice/label
274
-// in this function and no just when we get out of it?
275
-        window->hide();
276
-        window->show();
277
-    }
278
-
279
-    int x, y;
280
-    QString a2 = (QString)a[20];
281
-    QString b2 = (QString)b[20];
282
-    if (a2.toInt() == 6){
283
-        x = 12;
284
-    }
285
-    else{
286
-        x = a2.toInt();
287
-    }
288
-    if (b2.toInt() == 6){
289
-        y = 12;
290
-    }
291
-    else{
292
-        y = b2.toInt();
293
-    }
294
-
295
-    int total = x + y;
296
-    line[0]->setText(QString::number(total));
297
-}
298 115
 
299 116
 // =========================================================
300 117
 // Rock Paper Scissor Functions
301 118
 // =========================================================
302 119
 
303 120
 
304
-///
305
-/// \brief RPSAlpha
306
-/// \param p1
307
-/// \param p2
308
-/// \param score1
309
-/// \param score2
310
-/// \return
311
-///
312
-
313
-int RPSAlpha(char p1, char p2, int &score1, int &score2) {
121
+int RPSAlpha(char p1, char p2) {
314 122
     p1 = toupper(p1);
315 123
     p2 = toupper(p2);
316 124
     if ( p1 == 'P' ) {
317
-        if ( p2 == 'P' ) return 0;
318
-        else if (p2 == 'R') {
319
-            score1++; return 1;
320
-        }
321
-        else {
322
-            score2++; return 2;
323
-        }
125
+        if ( p2 == 'P' )    return TIE;
126
+        else if (p2 == 'R') return P1_WON;
127
+        else                return P2_WON;
324 128
     }
129
+
325 130
     else if (p1 == 'R') {
326
-        if ( p2 == 'R' ) return 0;
327
-        else if (p2 == 'S') {
328
-            score1++;    return 1;
329
-        }
330
-        else {
331
-            score2++;    return 2;
332
-        }
131
+        if ( p2 == 'R' )    return TIE;
132
+        else if (p2 == 'S') return P1_WON;
133
+        else                return P2_WON;
333 134
     }
135
+
334 136
     else {
335
-        if ( p2 == 'S' ) return 0;
336
-        else if (p2 == 'P') {
337
-            score1++;    return 1;
338
-        }
339
-        else {
340
-            score2++;    return 2;
341
-        }
137
+        if ( p2 == 'S' )    return TIE;
138
+        else if (p2 == 'P') return P1_WON;
139
+        else                return P2_WON;
342 140
     }
343 141
 }
344 142
 
345 143
 
346
-///
347
-/// \brief RPSBeta
348
-/// \param p1
349
-/// \param p2
350
-/// \param score1
351
-/// \param score2
352
-/// \return
353
-///
354
-
355
-int RPSBeta(char p1, char p2, int &score1, int &score2) {
144
+int RPSBeta(char p1, char p2) {
356 145
     p1 = toupper(p1);
357 146
     p2 = toupper(p2);
358 147
     if ( p1 == 'P' ) {
359
-        if ( p2 == 'S' ) return 0;
360
-        else if (p2 == 'R') {
361
-            score1++; return 1;
362
-        }
363
-        else {
364
-            score2++; return 2;
365
-        }
148
+        if ( p2 == 'S' )    return TIE;
149
+        else if (p2 == 'R') return P1_WON;
150
+        else                return P2_WON;
366 151
     }
367 152
     else if (p1 == 'R') {
368
-        if ( p2 == 'S' ) return 0;
369
-        else if (p2 == 'P') {
370
-            score1++;    return 1;
371
-        }
372
-        else {
373
-            score2++;    return 2;
374
-        }
153
+        if ( p2 == 'S' )    return TIE;
154
+        else if (p2 == 'P') return P1_WON;
155
+        else                return P2_WON;
375 156
     }
157
+
376 158
     else {
377
-        if ( p2 == 'S' ) return 0;
378
-        else if (p2 == 'R') {
379
-            score1++;    return 1;
380
-        }
381
-        else {
382
-            score2++;    return 2;
383
-        }
159
+        if ( p2 == 'S' )    return TIE;
160
+        else if (p2 == 'R') return P1_WON;
161
+        else                return P2_WON;
384 162
     }
385 163
 }
386 164
 
387 165
 
388
-///
389
-/// \brief RPSGamma
390
-/// \param p1
391
-/// \param p2
392
-/// \param score1
393
-/// \param score2
394
-/// \return
395
-///
396 166
 
397
-int RPSGamma(char p1, char p2, int &score1, int &score2) {
167
+int RPSGamma(char p1, char p2) {
398 168
     p1 = toupper(p1);
399 169
     p2 = toupper(p2);
400 170
     if ( p1 == 'P' ) {
401
-        if ( p2 == 'P' ) return 0;
402
-        else if (p2 == 'S') {
403
-            score1++; return 1;
404
-        }
405
-        else {
406
-            score2++; return 2;
407
-        }
171
+        if ( p2 == 'P' )    return TIE;
172
+        else if (p2 == 'S') return P1_WON;
173
+        else                return P2_WON;
408 174
     }
409 175
     else if (p1 == 'R') {
410
-        if ( p2 == 'R' ) return 0;
411
-        else if (p2 == 'P') {
412
-            score1++;    return 1;
413
-        }
414
-        else {
415
-            score2++;    return 2;
416
-        }
176
+        if ( p2 == 'R' )    return TIE;
177
+        else if (p2 == 'P') return P1_WON;
178
+        else                return P2_WON;
417 179
     }
418 180
     else {
419
-        if ( p2 == 'P' ) return 0;
420
-        else if (p2 == 'S') {
421
-            score1++;    return 1;
422
-        }
423
-        else {
424
-            score2++;    return 2;
425
-        }
181
+        if ( p2 == 'P' )    return TIE;
182
+        else if (p2 == 'S') return P1_WON;
183
+        else                return P2_WON;
426 184
     }
427 185
 }
428 186
 
429
-///
430
-/// \brief RPSDelta
431
-/// \param p1
432
-/// \param p2
433
-/// \param score1
434
-/// \param score2
435
-/// \return
436
-///
437 187
 
438
-int RPSDelta(char p1, char p2, int &score1, int &score2) {
188
+int RPSDelta(char p1, char p2) {
439 189
     p1 = toupper(p1);
440 190
     p2 = toupper(p2);
441 191
     if ( p1 == 'P' ) {
442
-        if ( p2 == 'P' ) return 0;
443
-        else if (p2 == 'S') {
444
-            score2++; return 1;
445
-        }
446
-        else {
447
-            score1++; return 2;
448
-        }
192
+        if ( p2 == 'P' )    return TIE;
193
+        else if (p2 == 'S') return P1_WON;
194
+        else                return P2_WON;
449 195
     }
450 196
     else if (p1 == 'R') {
451
-        if ( p2 == 'R' ) return 0;
452
-        else if (p2 == 'P') {
453
-            score2++;    return 1;
454
-        }
455
-        else {
456
-            score1++;    return 2;
457
-        }
197
+        if ( p2 == 'R' )    return TIE;
198
+        else if (p2 == 'P') return P1_WON;
199
+        else                return P2_WON;
458 200
     }
459 201
     else {
460
-        if ( p2 == 'P' ) return 0;
461
-        else if (p2 == 'S') {
462
-            score2++;    return 1;
463
-        }
464
-        else {
465
-            score1++;    return 2;
466
-        }
202
+        if ( p2 == 'P' )    return TIE;
203
+        else if (p2 == 'S') return P1_WON;
204
+        else                return P2_WON;
467 205
     }
468 206
 }
469 207
 
@@ -475,11 +213,6 @@ int RPSDelta(char p1, char p2, int &score1, int &score2) {
475 213
 
476 214
 QMap<int,QString> M;
477 215
 
478
-///
479
-/// \brief initCheckWMaps: initialize the values in the dictionary that is used throughout
480
-///                        the check functions.
481
-///
482
-
483 216
 void initCheckWMaps() {
484 217
 
485 218
     M[1] = "one";       M[2] = "two";       M[3]  = "three";      M[4] = "four";
@@ -493,13 +226,6 @@ void initCheckWMaps() {
493 226
 }
494 227
 
495 228
 
496
-///
497
-/// \brief validateCheckQty: determines is entered text is a valid number in [0,999999999]
498
-/// \param st text entered by the user
499
-/// \param qty text converted to integer
500
-/// \return true if the entered text is valid
501
-///
502
-
503 229
 bool validateCheckQty(QString st, unsigned int &qty) {
504 230
     int i = 0;
505 231
     for (i = 0; i < st.length() ; i++) {
@@ -512,13 +238,9 @@ bool validateCheckQty(QString st, unsigned int &qty) {
512 238
     return true;
513 239
 }
514 240
 
515
-///
516
-/// \brief wordForNumber: Given a number n in [0,999] returns the word equivalent
517
-/// \param n: the number
518
-/// \return a Qstring containing the number in words
519
-///
520 241
 
521
-QString wordForNumber(int n) {
242
+
243
+QString wordForNumber(unsigned int n) {
522 244
     QString st;
523 245
 
524 246
     int tens = n % 100;
@@ -539,13 +261,8 @@ QString wordForNumber(int n) {
539 261
 }
540 262
 
541 263
 
542
-///
543
-/// \brief checkWAlpha: One of the functions to convert a number in [0,999999999] to words
544
-/// \param n: the number
545
-/// \return a Qstring containing the number in words
546
-///
547 264
 
548
-QString checkWAlpha(int n) {
265
+QString checkWAlpha(unsigned int n) {
549 266
     QString st;
550 267
 
551 268
     // the cents
@@ -562,13 +279,8 @@ QString checkWAlpha(int n) {
562 279
     return st;
563 280
 }
564 281
 
565
-///
566
-/// \brief checkWBeta: One of the functions to convert a number in [0,999999999] to words
567
-/// \param n: the number
568
-/// \return a Qstring containing the number in words
569
-///
570 282
 
571
-QString checkWBeta(int n) {
283
+QString checkWBeta(unsigned int n) {
572 284
     QString st;
573 285
 
574 286
     st = wordForNumber(n % 1000);
@@ -580,13 +292,8 @@ QString checkWBeta(int n) {
580 292
     return st;
581 293
 }
582 294
 
583
-///
584
-/// \brief checkWGamma: One of the functions to convert a number in [0,999999999] to words
585
-/// \param n: the number
586
-/// \return a Qstring containing the number in words
587
-///
588 295
 
589
-QString checkWGamma(int n) {
296
+QString checkWGamma(unsigned int n) {
590 297
     QString st;
591 298
 
592 299
     st = wordForNumber(n % 10);
@@ -598,14 +305,9 @@ QString checkWGamma(int n) {
598 305
     return st;
599 306
 }
600 307
 
601
-///
602
-/// \brief checkWDelta: One of the functions to convert a number in [0,999999999] to words
603
-/// \param n: the number
604
-/// \return a Qstring containing the number in words
605
-///
606 308
 
607 309
 
608
-QString checkWDelta(int n) {
310
+QString checkWDelta(unsigned int n) {
609 311
     QString st;
610 312
 
611 313
     n /= 10;
@@ -640,11 +342,10 @@ bool validZuluTime(const QString &time, const QString &zone, int &hours, int &mi
640 342
     return true;
641 343
 }
642 344
 
643
-//This is the correct one
644 345
 
645 346
 QString zuluAlpha(int hours, int minutes, char zone) {
646 347
     int diff = 0;
647
-
348
+    zone = toupper(zone);
648 349
     if (zone <= 'I')         diff = zone - 'A' + 1;
649 350
     else if (zone <= 'M')    diff = 10 + (zone - 'K');
650 351
     else if (zone <= 'Y')    diff = -(zone - 'N' + 1);
@@ -652,7 +353,13 @@ QString zuluAlpha(int hours, int minutes, char zone) {
652 353
 
653 354
     hours = (hours + (24 + diff) ) % 24;
654 355
 
655
-    return QString::number(hours) + QString::number(minutes);
356
+    QString qstHours = QString::number(hours);
357
+    if (qstHours.length() == 1) qstHours.prepend("0");
358
+
359
+    QString qstMin = QString::number(minutes);
360
+    if (qstMin.length() == 1) qstMin.prepend("0");
361
+
362
+    return qstHours + qstMin;
656 363
 }
657 364
 
658 365
 QString zuluBeta(int hours, int minutes, char zone) {
@@ -692,161 +399,3 @@ QString zuluDelta(int hours, int minutes, char zone) {
692 399
 
693 400
     return QString::number(hours)  + QString::number(minutes);
694 401
 }
695
-
696
-
697
-
698
-// =========================================================
699
-// APFT Functions
700
-// =========================================================
701
-
702
-
703
-//This it the correct one
704
-
705
-void MainWindow::APFTAlpha(){
706
-    //For each one of these variables we apply the formula that they use
707
-    //to set the points
708
-    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
709
-
710
-    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
711
-
712
-    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
713
-    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
714
-
715
-    //Since the maximum of points that one can obtain
716
-    //on each excercise type is 100, we restrict it
717
-    if (sit_ups > 100){
718
-        sit_ups = 100;
719
-    }
720
-    else if (sit_ups < 0){
721
-        sit_ups = 0;
722
-    }
723
-    if (push_ups > 100){
724
-        push_ups = 100;
725
-    }
726
-    else if (push_ups < 0){
727
-        push_ups = 0;
728
-    }
729
-    if (two_mile_run > 100){
730
-        two_mile_run = 100;
731
-    }
732
-    else if (two_mile_run < 0){
733
-        two_mile_run = 0;
734
-    }
735
-
736
-    //Finally we set the outputs.
737
-    line[3]->setText(QString::number(sit_ups));
738
-    line[4]->setText(QString::number(push_ups));
739
-    line[5]->setText(QString::number(two_mile_run));
740
-    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
741
-    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
742
-        label[7]->setText("PASS");
743
-    }
744
-    else{
745
-        label[7]->setText("FAIL");
746
-    }
747
-}
748
-
749
-//This one do not check if the number is greater than 100
750
-
751
-void MainWindow::APFTBeta(){
752
-    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
753
-
754
-    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
755
-
756
-    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
757
-    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
758
-
759
-    line[3]->setText(QString::number(sit_ups));
760
-    line[4]->setText(QString::number(push_ups));
761
-    line[5]->setText(QString::number(two_mile_run));
762
-    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
763
-    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
764
-        line[7]->setText("PASS");
765
-    }
766
-    else{
767
-        line[7]->setText("FAIL");
768
-    }
769
-}
770
-
771
-//This one switch the results
772
-
773
-void MainWindow::APFTGamma(){
774
-    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
775
-    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
776
-    double running_time = qFloor((line[2]->text().left(2).append('.' + line[2]->text().right(2))).toDouble());
777
-    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
778
-
779
-    if (sit_ups > 100){
780
-        sit_ups = 100;
781
-    }
782
-    else if (sit_ups < 0){
783
-        sit_ups = 0;
784
-    }
785
-    if (push_ups > 100){
786
-        push_ups = 100;
787
-    }
788
-    else if (push_ups < 0){
789
-        push_ups = 0;
790
-    }
791
-    if (two_mile_run > 100){
792
-        two_mile_run = 100;
793
-    }
794
-    else if (two_mile_run < 0){
795
-        two_mile_run = 0;
796
-    }
797
-
798
-    line[5]->setText(QString::number(sit_ups));
799
-    line[3]->setText(QString::number(push_ups));
800
-    line[4]->setText(QString::number(two_mile_run));
801
-    line[6]->setText(QString::number(push_ups + sit_ups + two_mile_run));
802
-    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
803
-        line[7]->setText("PASS");
804
-    }
805
-    else{
806
-        line[7]->setText("FAIL");
807
-    }
808
-}
809
-
810
-//This one do not sums the points but the quantities of each excercise
811
-
812
-void MainWindow::APFTDelta(){
813
-    double sit_ups = qFloor(line[0]->text().toDouble() * 1.6 - 24.8);
814
-    double push_ups = qFloor(line[1]->text().toInt() * 1.42);
815
-    double running_time = qFloor((line[2]->text().left(2).append('.'
816
-                                   + line[2]->text().right(2))).toDouble());
817
-    double two_mile_run = qFloor((820 / 3) - ((40 * running_time) / 3));
818
-
819
-    if (sit_ups > 100){
820
-        sit_ups = 100;
821
-    }
822
-    else if (sit_ups < 0){
823
-        sit_ups = 0;
824
-    }
825
-    if (push_ups > 100){
826
-        push_ups = 100;
827
-    }
828
-    else if (push_ups < 0){
829
-        push_ups = 0;
830
-    }
831
-    if (two_mile_run > 100){
832
-        two_mile_run = 100;
833
-    }
834
-    else if (two_mile_run < 0){
835
-        two_mile_run = 0;
836
-    }
837
-
838
-    int sumaTo = line[0]->text().toInt() + line[1]->text().toInt() + running_time;
839
-    line[3]->setText(QString::number(sit_ups));
840
-    line[4]->setText(QString::number(push_ups));
841
-    line[5]->setText(QString::number(two_mile_run));
842
-    line[6]->setText(QString::number(sumaTo));
843
-    if (push_ups >= 60 && sit_ups >= 60 && two_mile_run >= 60){
844
-        line[7]->setText("PASS");
845
-    }
846
-    else{
847
-        line[7]->setText("FAIL");
848
-    }
849
-}
850
-
851
-
852
-

+ 296
- 8
functions.h 파일 보기

@@ -4,28 +4,316 @@
4 4
 #include <string>
5 5
 using namespace std;
6 6
 
7
+
8
+/// \fn validateSorts
9
+/// \~English
10
+/// \brief Function to validate that sort is invoked with non-empty strings
11
+/// \param a first QSring
12
+/// \param b second Qstring
13
+/// \param c third QString
14
+/// \return true if non of the QStrings are empty
15
+/// \~Spanish
16
+/// \brief Valida que los QStrings que se van a ordenar no estén vacios.
17
+/// \param a primer QSring
18
+/// \param b segundo Qstring
19
+/// \param c tercer QString
20
+/// \return true si ninguno de los QString está vacio
7 21
 bool validateSorts(const QString &a, const QString &b, const QString &c);
22
+
23
+/// \fn mySortAlpha
24
+/// \~English
25
+/// \brief A function to sort the QStrings. Returns the order 
26
+/// strings through the parameters (a is smallest, c is largest).
27
+/// \param a reference to first QSring
28
+/// \param b reference to second Qstring
29
+/// \param c reference to third QString
30
+/// \~Spanish
31
+/// \brief Función para ordenar QStrings. Devuelve los QStrings
32
+/// ordenados a través de los parámetros (a para el menor, c para el mayor).
33
+/// \param a referencia al primer QSring
34
+/// \param b referencia al segundo Qstring
35
+/// \param c referencia al tercer QString
8 36
 void mySortAlpha(QString &a, QString &b, QString &c);
37
+
38
+/// \fn mySortBeta
39
+/// \~English
40
+/// \brief A function to sort the QStrings. Returns the order 
41
+/// strings through the parameters (a is smallest, c is largest).
42
+/// \param a reference to first QSring
43
+/// \param b reference to second Qstring
44
+/// \param c reference to third QString
45
+/// \~Spanish
46
+/// \brief Función para ordenar QStrings. Devuelve los QStrings
47
+/// ordenados a través de los parámetros (a para el menor, c para el mayor).
48
+/// \param a referencia al primer QSring
49
+/// \param b referencia al segundo Qstring
50
+/// \param c referencia al tercer QString
9 51
 void mySortBeta(QString &a, QString &b, QString &c);
52
+
53
+/// \fn mySortGamma
54
+/// \~English
55
+/// \brief A function to sort the QStrings. Returns the order 
56
+/// strings through the parameters (a is smallest, c is largest).
57
+/// \param a reference to first QSring
58
+/// \param b reference to second Qstring
59
+/// \param c reference to third QString
60
+/// \~Spanish
61
+/// \brief Función para ordenar QStrings. Devuelve los QStrings
62
+/// ordenados a través de los parámetros (a para el menor, c para el mayor).
63
+/// \param a referencia al primer QSring
64
+/// \param b referencia al segundo Qstring
65
+/// \param c referencia al tercer QString
10 66
 void mySortGamma(QString &a, QString &b, QString &c);
67
+
68
+/// \fn mySortDelta
69
+/// \~English
70
+/// \brief First function to sort the QStrings. Returns the order 
71
+/// strings through the parameters (a is smallest, c is largest).
72
+/// \param a reference to first QSring
73
+/// \param b reference to second Qstring
74
+/// \param c reference to third QString
75
+/// \~Spanish
76
+/// \brief Función para ordenar QStrings. Devuelve los QStrings
77
+/// ordenados a través de los parámetros (a para el menor, c para el mayor).
78
+/// \param a referencia al primer QSring
79
+/// \param b referencia al segundo Qstring
80
+/// \param c referencia al tercer QString
11 81
 void mySortDelta(QString &a, QString &b, QString &c);
12 82
 
83
+
84
+/// \fn validZuluTime
85
+/// \~English
86
+/// \brief Function to validate the arguments that will be passed to the
87
+///  Zulu functions.  Returns the integer hour and minutes through last two parameters.
88
+/// \param time QString that contains the time in military format.
89
+/// \param zone  QString that specifies military zone.
90
+/// \param hours hours, extracted from the time parameter
91
+/// \param minutes minutes, extracted from the time parameter
92
+/// \return true if the time and zone are valid. 
93
+/// \~Spanish
94
+/// \brief Función para validar los argumentos que serán pasados a
95
+/// funciones Zulu.  Devuelve (como enteros) la hora y minutos a través de los 
96
+/// últimos dos parámetros.
97
+/// \param time QString que contiene la hora en formato militar, e.g. "15:22"
98
+/// \param zone  QString que contiene zona militar.
99
+/// \param hours horas, extraida del argumento pasado a time.
100
+/// \param minutes minutos, extraidos del argumento pasado a time.
101
+/// \return true si la hora (time) y la zona son válidas. 
13 102
 bool validZuluTime(const QString &time, const QString &zone, int &hours, int &minutes);
103
+
104
+
105
+/// \fn zuluAlpha
106
+/// \~English
107
+/// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString)
108
+/// \param hours 
109
+/// \param minutes 
110
+/// \param zone 
111
+/// \return a QString of the Zulu time, in military time format
112
+/// \~Spanish
113
+/// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString)
114
+/// \param hours 
115
+/// \param minutes 
116
+/// \param zone 
117
+/// \return un QString del tiempo Zulu, en formato de hora militar.
14 118
 QString zuluAlpha(int hours, int minutes, char zone);
119
+
120
+
121
+/// \fn zuluBeta
122
+/// \~English
123
+/// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString)
124
+/// \param hours 
125
+/// \param minutes 
126
+/// \param zone 
127
+/// \return a QString of the Zulu time, in military time format
128
+/// \~Spanish
129
+/// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString)
130
+/// \param hours 
131
+/// \param minutes 
132
+/// \param zone 
133
+/// \return un QString del tiempo Zulu, en formato de hora militar.
15 134
 QString zuluBeta(int hours, int minutes, char zone);
135
+
136
+
137
+/// \fn zuluGamma
138
+/// \~English
139
+/// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString)
140
+/// \param hours 
141
+/// \param minutes 
142
+/// \param zone 
143
+/// \return a QString of the Zulu time, in military time format
144
+/// \~Spanish
145
+/// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString)
146
+/// \param hours 
147
+/// \param minutes 
148
+/// \param zone 
149
+/// \return un QString del tiempo Zulu, en formato de hora militar.
16 150
 QString zuluGamma(int hours, int minutes, char zone);
151
+
152
+
153
+/// \fn zuluDelta
154
+/// \~English
155
+/// \brief Given the hour, minutes and military zone returns the Zulu time (as a QString)
156
+/// \param hours 
157
+/// \param minutes 
158
+/// \param zone 
159
+/// \return a QString of the Zulu time, in military time format
160
+/// \~Spanish
161
+/// \brief Dado la hora, minutos y zona militar devuelve el tiempo Zulu (como QString)
162
+/// \param hours 
163
+/// \param minutes 
164
+/// \param zone 
165
+/// \return un QString del tiempo Zulu, en formato de hora militar.
17 166
 QString zuluDelta(int hours, int minutes, char zone);
18 167
 
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 168
 
169
+// Constants for the rock, paper, scisor functions.
170
+const int TIE = 0;
171
+const int P1_WON = 1;
172
+const int P2_WON = 2;
173
+
174
+
175
+/// \fn RPSAlpha
176
+/// \~English
177
+/// \brief Given play by the first and second players, returns who won the rock, paper
178
+/// scisors match.
179
+/// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' 
180
+/// \param p2 play by the first player, as represented by char 'R', 'P' or 'S'  
181
+/// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won.
182
+/// \~Spanish
183
+/// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, 
184
+/// papel y tijera ((R)ock, (P)aper, (S)cisors)
185
+/// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') 
186
+/// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S')
187
+/// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo.
188
+int RPSAlpha(char p1, char p2);
189
+
190
+/// \fn RPSBeta
191
+/// \~English
192
+/// \brief Given play by the first and second players, returns who won the rock, paper
193
+/// scisors match.
194
+/// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' 
195
+/// \param p2 play by the first player, as represented by char 'R', 'P' or 'S'  
196
+/// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won.
197
+/// \~Spanish
198
+/// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, 
199
+/// papel y tijera ((R)ock, (P)aper, (S)cisors)
200
+/// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') 
201
+/// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S')
202
+/// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo.
203
+int RPSBeta(char p1, char p2);
204
+
205
+/// \fn RPSGamma
206
+/// \~English
207
+/// \brief Given play by the first and second players, returns who won the rock, paper
208
+/// scisors match.
209
+/// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' 
210
+/// \param p2 play by the first player, as represented by char 'R', 'P' or 'S'  
211
+/// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won.
212
+/// \~Spanish
213
+/// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, 
214
+/// papel y tijera ((R)ock, (P)aper, (S)cisors)
215
+/// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') 
216
+/// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S')
217
+/// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo.
218
+int RPSGamma(char p1, char p2);
219
+
220
+/// \fn RPSDelta
221
+/// \~English
222
+/// \brief Given play by the first and second players, returns who won the rock, paper
223
+/// scisors match.
224
+/// \param p1 play by the first player, as represented by char 'R', 'P' or 'S' 
225
+/// \param p2 play by the first player, as represented by char 'R', 'P' or 'S'  
226
+/// \return a 0 if there was a tie, 1 if the first player won, 2 if the second player won.
227
+/// \~Spanish
228
+/// \brief Dado la jugada del jugador 1 y 2, devuelve quien ganó el juego de piedra, 
229
+/// papel y tijera ((R)ock, (P)aper, (S)cisors)
230
+/// \param p1 jugada del primer jugador, representada por un caracter ('R','P','S') 
231
+/// \param p1 jugada del segundo jugador, representada por un caracter ('R','P','S')
232
+/// \param zone 
233
+/// \return a 0 si hubo empate, 1 si ganó el primer jugador, 2 si ganó el segundo.
234
+int RPSDelta(char p1, char p2);
235
+
236
+
237
+/// \fn initCheckWMaps
238
+/// \~English
239
+/// \brief Initialize the values in the dictionary (M) that is used throughout
240
+/// the check functions.
241
+/// \~Spanish
242
+/// \brief Inicializa los valores del diccionario que se utiliza a través del 
243
+/// las funciones 'check' 
24 244
 void initCheckWMaps();
245
+
246
+
247
+
248
+/// \fn validateCheckQty
249
+/// \~English
250
+/// \brief Given a QString determines its numerical value and if the 
251
+/// the value is in the range [0,999999999]
252
+/// \param st a QString with a numeric value, e.g. "4520"
253
+/// \param qty unsigned integer to return the numeric value, e.g. 4520
254
+/// \return true if the QString was converted to an integer and is in the valid range
255
+/// \~Spanish
256
+/// \brief Dado un string determina su valor numérico y si el valor está en el 
257
+/// rango [0,999999999]
258
+/// \param st un QString con un valor numérico, e.g. "4520"
259
+/// \param qty entero sin signo para devolver el valor numérico, e.g. 4520
260
+/// \return true si el QString se pudo convertir a entero y está en el rango
25 261
 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);
262
+
263
+
264
+/// \fn wordForNumber
265
+/// \~English
266
+/// \brief Given a number n in [0,999] returns the word equivalent
267
+/// \param n the unsigned integer, e.g. 34
268
+/// \return a QString containing the number in words, e.g. "thirty four"
269
+/// \~Spanish
270
+/// \brief Dado un número entero en el rango [0,999] devuelve su representación en palabras
271
+/// \param n el entero sin signo, e.g. 34
272
+/// \return un QString que contiene el valor en palabras, e.g. "thirty four"
273
+QString wordForNumber(unsigned int n);
274
+
275
+/// \fn checkWAlpha
276
+/// \~English
277
+/// \brief Given a unsigned integer returns its value as a string of words (in English)
278
+/// \param n the unsigned integer, e.g. 42
279
+/// \return QString containing the value (in words), e.g. "fourty two"
280
+/// \~Spanish
281
+/// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English)
282
+/// \param n el entero sin signo, e.g. 42
283
+/// \return QString que contien el valor en palabras, e.g. "fourty two"
284
+QString checkWAlpha(unsigned int n);
285
+
286
+/// \fn checkWBeta
287
+/// \~English
288
+/// \brief Given a unsigned integer returns its value as a string of words (in English)
289
+/// \param n the unsigned integer, e.g. 42
290
+/// \return QString containing the value (in words), e.g. "fourty two"
291
+/// \~Spanish
292
+/// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English)
293
+/// \param n el entero sin signo, e.g. 42
294
+/// \return QString que contien el valor en palabras, e.g. "fourty two"
295
+QString checkWBeta(unsigned int n);
296
+
297
+/// \fn checkWGamma
298
+/// \~English
299
+/// \brief Given a unsigned integer returns its value as a string of words (in English)
300
+/// \param n the unsigned integer, e.g. 42
301
+/// \return QString containing the value (in words), e.g. "fourty two"
302
+/// \~Spanish
303
+/// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English)
304
+/// \param n el entero sin signo, e.g. 42
305
+/// \return QString que contien el valor en palabras, e.g. "fourty two"
306
+QString checkWGamma(unsigned int n);
307
+
308
+/// \fn checkWDelta
309
+/// \~English
310
+/// \brief Given a unsigned integer returns its value as a string of words (in English)
311
+/// \param n the unsigned integer, e.g. 42
312
+/// \return QString containing the value (in words), e.g. "fourty two"
313
+/// \~Spanish
314
+/// \brief Dado un entero sin signo devuelve su valor como un string de palabras (in English)
315
+/// \param n el entero sin signo, e.g. 42
316
+/// \return QString que contien el valor en palabras, e.g. "fourty two"
317
+QString checkWDelta(unsigned int n);
30 318
 
31 319
 #endif // FUNCTIONS_H

+ 1
- 49
main.cpp 파일 보기

@@ -6,65 +6,17 @@
6 6
 #include <cassert>
7 7
 #include <QDebug>
8 8
 
9
-void testSort() {
10
-    QString a = "AAA" , b = "BBB" , c = "CCC";
11
-    mySortBeta(a,b,c);
12
-    assert( a < b && b < c);
13 9
 
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 10
 
50 11
 int main(int argc, char *argv[])
51 12
 {
52
-//    testSort();
53
-    initCheckWMaps(); /*** DONT FORGET ***/
54
-
55
-//    testCheck();
56
-//    qDebug() << checkWAlpha(91);
57
-//    qDebug() << checkWAlpha(891);
58
-//    qDebug() << checkWAlpha(801);
59 13
 
14
+    initCheckWMaps(); 
60 15
 
61 16
     srand(time(NULL));
62 17
     QApplication a(argc, argv);
63 18
     MainWindow w;
64
-    w.setWindowTitle("Testing Lab");
65 19
     w.show();
66 20
 
67
-
68
-
69 21
     return a.exec();
70 22
 }

+ 126
- 439
mainwindow.cpp 파일 보기

@@ -1,8 +1,12 @@
1
+// RAN 2015-06-26 - Added Zulu Zone label
2
+//   - Removed the onclick functions for the buttons that are no longer used
3
+
1 4
 #include "mainwindow.h"
2 5
 #include "ui_mainwindow.h"
3 6
 #include "secondwindow.cpp"
4 7
 
5 8
 #include <QDebug>
9
+#include <QTimer>
6 10
 #include <QtCore/qmath.h>
7 11
 #include <QMessageBox>
8 12
 #include "functions.h"
@@ -38,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) :
38 42
 
39 43
     // We need to know whenever the second window is closed to show the
40 44
     // main window, or to hide when the second one is showed
41
-    connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
45
+    connect(window, SIGNAL(closeIt(bool)), this, SLOT(showMW(bool)));
42 46
 
43 47
     if(!dice1.load(":/images/resources/d1.png") || !dice2.load(":/images/resources/d1.png")){
44 48
         qDebug() << "Error1 Loading image";
@@ -52,9 +56,8 @@ MainWindow::~MainWindow()
52 56
     delete ui;
53 57
 }
54 58
 
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){
59
+void MainWindow::showMW(bool doShow){
60
+    if (doShow){
58 61
         show();
59 62
 
60 63
         // Deleting pointers and point them to NULL
@@ -76,14 +79,13 @@ void MainWindow::mostrar(bool si){
76 79
 
77 80
         // Create the new window and connecting it again with the signal
78 81
         window = new secondwindow;
79
-        connect(window, SIGNAL(cerrado(bool)), this, SLOT(mostrar(bool)));
82
+        connect(window, SIGNAL(closeIt(bool)), this, SLOT(showMW(bool)));
80 83
     }
81 84
     else hide();
82 85
 }
83 86
 
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
+
88
+void MainWindow::setOption(QString str){
87 89
     option = str;
88 90
 }
89 91
 
@@ -97,212 +99,8 @@ void MainWindow::clearLines(){
97 99
     score1 = score2 = 0;
98 100
 }
99 101
 
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 102
 
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(){
103
+void MainWindow::callOneOfTheSorts(){
306 104
     QString a = line[0]->text();
307 105
     QString b = line[1]->text();
308 106
     QString c = line[2]->text();
@@ -331,16 +129,12 @@ void MainWindow::sorts(){
331 129
 }
332 130
 
333 131
 
132
+void MainWindow::callOneOfTheRPS(){
334 133
 
134
+    QString p1 = this->cmbPlayer01->currentText();
135
+    QString p2 = this->cmbPlayer02->currentText();
335 136
 
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) {
137
+    if (p1.length() * p2.length() == 0) {
344 138
         QMessageBox::warning(this, "Alert",
345 139
                              "Please provide a play for both players and the number of games to win");
346 140
         return;
@@ -348,50 +142,100 @@ void MainWindow::RPSs(){
348 142
 
349 143
     int winnerNum;
350 144
     if (option == "Version Alpha")
351
-        winnerNum = RPSAlpha(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
145
+        winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
352 146
     else if (option == "Version Beta")
353
-        winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
147
+        winnerNum = RPSBeta(p1.toStdString()[0], p2.toStdString()[0]);
354 148
     else if (option == "Version Gamma")
355
-        winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
149
+        winnerNum = RPSGamma(p1.toStdString()[0], p2.toStdString()[0]);
356 150
     else
357
-        winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0], score1, score2);
151
+        winnerNum = RPSDelta(p1.toStdString()[0], p2.toStdString()[0]);
358 152
 
359 153
     QString st;
360 154
 
155
+
361 156
     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";
157
+        case 1:  st = "Player 1"; break;
158
+        case 2:  st = "Player 2"; break;
159
+        case 0:  st = "Tie"; break;
160
+        default: st = "Error";
366 161
     }
367 162
 
368
-    line[3]->setText(st);
163
+    line[0]->setText(st);
369 164
 
370
-    line[4]->setText(QString::number(score1) + " to " + QString::number(score2));
165
+}
371 166
 
372
-    if (score1 == gamesToWin.toInt() || score2 == gamesToWin.toInt() ) {
373
-        QMessageBox::warning(this, "Alert",
374
-                             "Game won by " + st + "!!!");
375
-        score1 = score2 = 0;
167
+
168
+void MainWindow::paintDice() {
169
+    this->timerCounter++;
170
+    int a, b;
171
+    a = rand()%6;
172
+    b = rand()%6;
173
+    label[3]->setPixmap(QPixmap::fromImage(diceImages[a]));
174
+    label[4]->setPixmap(QPixmap::fromImage(diceImages[b]));
175
+    if (this->timerCounter == 10) {
176
+        aTimer->stop();
177
+        diceFinal01 = a;
178
+        diceFinal02 = b;
179
+        if (option == "Version Alpha")
180
+            diceBeta();
181
+        else if (option == "Version Beta")
182
+            diceGamma();
183
+        else if (option == "Version Gamma")
184
+            diceAlpha();
185
+        else
186
+            diceAlpha();
376 187
     }
188
+}
189
+
190
+
191
+void MainWindow::callOneOfTheDices(){
192
+
193
+    for (int i = 1; i <= 6; i++)
194
+        this->diceImages.push_back(QImage(":/images/resources/d" + QString::number(i) + ".png"));
195
+
196
+    aTimer = new QTimer;
197
+    aTimer->setInterval(100);
198
+    aTimer->setSingleShot(false);
199
+    aTimer->start();
200
+    timerCounter = 0;
201
+    QObject::connect(aTimer,&QTimer::timeout, this, &MainWindow::paintDice); //[&](){ birth(w, juana, avelardo, piolin);});
202
+
377 203
 
378 204
 }
379 205
 
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();
206
+
207
+
208
+
209
+//========================================================
210
+// Functions for the dice roller
211
+//========================================================
212
+
213
+
214
+void MainWindow::diceAlpha(){
215
+    int total = diceFinal01 + diceFinal02 + 2;
216
+    line[0]->setText(QString::number(total));
217
+}
218
+
219
+
220
+void MainWindow::diceBeta(){
221
+    int total = diceFinal01 + diceFinal01 + 2;
222
+    line[0]->setText(QString::number(total));
223
+}
224
+
225
+
226
+void MainWindow::diceGamma(){
227
+    int total = diceFinal01 - diceFinal02;
228
+    line[0]->setText(QString::number(total));
229
+}
230
+
231
+
232
+void MainWindow::diceDelta(){
233
+    int total = diceFinal01 + diceFinal02;
234
+    line[0]->setText(QString::number(total));
390 235
 }
391 236
 
392 237
 
393
-//Checks which version of check-writer is selected and call it
394
-void MainWindow::checkWs(){
238
+void MainWindow::callOneOfTheChecks(){
395 239
     unsigned int qty;
396 240
     if (!validateCheckQty(line[0]->text(),qty)) {
397 241
         QMessageBox::warning(this, "Alert",
@@ -408,8 +252,7 @@ void MainWindow::checkWs(){
408 252
         line[1]->setText( checkWDelta(qty) );
409 253
 }
410 254
 
411
-//Checks which version of zulu is selected and call it
412
-void MainWindow::zulus(){
255
+void MainWindow::callOneOfTheZulus(){
413 256
     QString zuluTime = line[0]->text();
414 257
     QString zuluZone = line[1]->text();
415 258
     int hours, minutes;
@@ -417,7 +260,7 @@ void MainWindow::zulus(){
417 260
     if (!validZuluTime(zuluTime, zuluZone, hours, minutes) ) {
418 261
 
419 262
         QMessageBox::warning(this, "Alert",
420
-                             "Either Zulu Time or Zone is not valid");
263
+                             "Either Zulu Time or Zone is not valid.");
421 264
         line[2]->setText("Error");
422 265
         return;
423 266
     }
@@ -432,23 +275,7 @@ void MainWindow::zulus(){
432 275
 
433 276
 }
434 277
 
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 278
 
451
-//Here is what happend when Sort-button is clicked
452 279
 void MainWindow::on_SortsButton_clicked()
453 280
 {
454 281
     //Create a new QComboBox and add the items in it
@@ -495,19 +322,18 @@ void MainWindow::on_SortsButton_clicked()
495 322
 
496 323
     //Here we connect the signals of the widgets generated
497 324
     //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()));
325
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
326
+    connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheSorts()));
500 327
     connect(button[1], SIGNAL(clicked()), this, SLOT(clearLines()));
501 328
 
502 329
     //Now that we have set our new window, we hide the main-window
503 330
     //and show the new one. The new-window has a signal that
504 331
     //notify when it was closed so we can shor the main-window
505 332
     window->setLayout(layout);
506
-    mostrar(false);
333
+    showMW(false);
507 334
     window->show();
508 335
 }
509 336
 
510
-//Here is what happend when Dice-button is clicked
511 337
 void MainWindow::on_DiceButton_clicked()
512 338
 {
513 339
     //Create a new QComboBox and add the items in it
@@ -551,18 +377,17 @@ void MainWindow::on_DiceButton_clicked()
551 377
 
552 378
     //Here we connect the signals of the widgets generated
553 379
     //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()));
380
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
381
+    connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheDices()));
556 382
 
557 383
     //Now that we have set our new window, we hide the main-window
558 384
     //and show the new one. The new-window has a signal that
559 385
     //notify when it was closed so we can shor the main-window
560 386
     window->setLayout(layout);
561
-    mostrar(false);
387
+    showMW(false);
562 388
     window->show();
563 389
 }
564 390
 
565
-//Here is what happend when RPS-button is clicked
566 391
 void MainWindow::on_RPSButton_clicked()
567 392
 {
568 393
     //Create a new QComboBox and add the items in it
@@ -573,117 +398,52 @@ void MainWindow::on_RPSButton_clicked()
573 398
     method->addItem("Version Delta");
574 399
     option = "Version Alpha"; //Default option is alpha
575 400
 
576
-    //We create a new layout and insert the comboBox to it
577
-    layout = new QGridLayout;
578
-    layout->addWidget(method, 0, 0, 1, -1);
401
+    cmbPlayer01 = new QComboBox;
402
+    cmbPlayer02 = new QComboBox;
403
+    cmbPlayer01->addItem("rock");       cmbPlayer02->addItem("rock");
404
+    cmbPlayer01->addItem("paper");      cmbPlayer02->addItem("paper");
405
+    cmbPlayer01->addItem("scisors");    cmbPlayer02->addItem("scisors");
406
+
579 407
 
580 408
     //The buttons needed here are the 'play' and 'clear' buttons
581 409
     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 410
 
411
+    line[0] = new QLineEdit;
589 412
     //The user is not able to write on the output line
590
-    line[3]->setEnabled(false);
413
+    line[0]->setEnabled(false);
591 414
 
592 415
     //Labels to let the user understand the app
593 416
     label[0] = new QLabel("Player 1's moves");
594 417
     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
418
+    label[2] = new QLabel("Winner:");
644 419
 
645 420
     //We create a new layout and insert the comboBox to it
421
+    int row = 0;
646 422
     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");
423
+    layout->addWidget(method,       row++, 0);
424
+    layout->addWidget(label[0],     row, 0);
425
+    layout->addWidget(cmbPlayer01,  row++, 1);
426
+    layout->addWidget(label[1],     row, 0);
427
+    layout->addWidget(cmbPlayer02,  row++, 1);
428
+    layout->addWidget(button[0],    row++, 1);
429
+    layout->addWidget(line[0],      row, 1);
430
+    layout->addWidget(label[2],      row++, 0);
651 431
 
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 432
 
671 433
     //Here we connect the signals of the widgets generated
672 434
     //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)));
435
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
436
+    connect(button[0], SIGNAL(clicked()), this, SLOT(callOneOfTheRPS()));
677 437
 
678 438
     //Now that we have set our new window, we hide the main-window
679 439
     //and show the new one. The new-window has a signal that
680 440
     //notify when it was closed so we can shor the main-window
681 441
     window->setLayout(layout);
682
-    mostrar(false);
442
+    showMW(false);
683 443
     window->show();
684 444
 }
685 445
 
686
-//Here is what happend when Zulu-button is clicked
446
+
687 447
 void MainWindow::on_ZuluButton_clicked()
688 448
 {
689 449
     //Create a new QComboBox and add the items in it
@@ -701,6 +461,7 @@ void MainWindow::on_ZuluButton_clicked()
701 461
     //Labels to let the user understand the app
702 462
     label[0] = new QLabel("Zulu time:");
703 463
     label[1] = new QLabel("Standard time");
464
+    label[2] = new QLabel("Zulu zone:");
704 465
 
705 466
     //Just the buttons to clear and convert the time
706 467
     button[0] = new QPushButton("Clear");
@@ -716,6 +477,7 @@ void MainWindow::on_ZuluButton_clicked()
716 477
 
717 478
     //Here we insert the widgets on the layout
718 479
     layout->addWidget(label[0], 1, 0);
480
+    layout->addWidget(label[2], 1, 1);
719 481
     layout->addWidget(line[0], 2, 0);
720 482
     layout->addWidget(line[1], 2, 1);
721 483
     layout->addWidget(button[0], 3, 0);
@@ -725,9 +487,9 @@ void MainWindow::on_ZuluButton_clicked()
725 487
 
726 488
     //Here we connect the signals of the widgets generated
727 489
     //by code to their respective functions
728
-    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(whatOption(QString)));
490
+    connect(method, SIGNAL(currentIndexChanged(QString)), this, SLOT(setOption(QString)));
729 491
     connect(button[0], SIGNAL(clicked()), this, SLOT(clearLines()));
730
-    connect(button[1], SIGNAL(clicked()), this, SLOT(zulus()));
492
+    connect(button[1], SIGNAL(clicked()), this, SLOT(callOneOfTheZulus()));
731 493
 
732 494
     // Rafa 2014-09-16 - Validation will be done when button is clicked
733 495
     //    connect(line[0], SIGNAL(textEdited(QString)), this, SLOT(Zulunormalizer1(QString)));
@@ -737,82 +499,7 @@ void MainWindow::on_ZuluButton_clicked()
737 499
     //and show the new one. The new-window has a signal that
738 500
     //notify when it was closed so we can shor the main-window
739 501
     window->setLayout(layout);
740
-    mostrar(false);
502
+    showMW(false);
741 503
     window->show();
742 504
 }
743 505
 
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
-}

+ 160
- 45
mainwindow.h 파일 보기

@@ -1,3 +1,5 @@
1
+// RAN - 2015-06-26 - Removed some old slots that were not being used
2
+
1 3
 #ifndef MAINWINDOW_H
2 4
 #define MAINWINDOW_H
3 5
 
@@ -12,6 +14,7 @@
12 14
 #include <QComboBox>
13 15
 #include <QString>
14 16
 #include <QImage>
17
+#include <QVector>
15 18
 
16 19
 namespace Ui {
17 20
     class MainWindow;
@@ -25,75 +28,187 @@ public:
25 28
     explicit MainWindow(QWidget *parent = 0);
26 29
     ~MainWindow();
27 30
 
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 31
 
50
-    void clearLines();
51
-
52
-    void RPSnormalizer1(QString str);
32
+    /// \fn diceAlpha
33
+    /// \~English
34
+    /// \brief Computes the dice total based on the values of the dice.
35
+    /// \~Spanish
36
+    /// \brief Computa el total de puntos usando los valores de los dados.
37
+    void diceAlpha();
53 38
 
54
-    void RPSnormalizer2(QString str);
55 39
 
56
-    void RPSnormalizer3(QString str);
40
+    /// \fn diceBeta
41
+    /// \~English
42
+    /// \brief Computes the dice total based on the values of the dice.
43
+    /// \~Spanish
44
+    /// \brief Computa el total de puntos usando los valores de los dados.
45
+    void diceBeta();
57 46
 
58
-    void CheckWnormalizer(QString str);
47
+    /// \fn diceGamma
48
+    /// \~English
49
+    /// \brief Computes the dice total based on the values of the dice.
50
+    /// \~Spanish
51
+    /// \brief Computa el total de puntos usando los valores de los dados.
52
+    void diceGamma();
59 53
 
60
-    void Zulunormalizer1(QString str);
54
+    /// \fn diceDelta
55
+    /// \~English
56
+    /// \brief Computes the dice total based on the values of the dice.
57
+    /// \~Spanish
58
+    /// \brief Computa el total de puntos usando los valores de los dados.
59
+    void diceDelta();
61 60
 
62
-    void Zulunormalizer2(QString str);
63 61
 
64
-    void APFTnormalizer1(QString str);
62
+private slots:
65 63
 
66
-    void APFTnormalizer2(QString str);
67 64
 
68
-    void APFTnormalizer3(QString str);
65
+    /// \fn on_SortsButton_clicked
66
+    /// \~English
67
+    /// \brief Called when Sort-button is clicked. Creates controls for secondary window,
68
+    /// displays it, and hides the main window.
69
+    /// \~Spanish
70
+    /// \brief Esta función es llamada cuando el usuario cliquea el boton de Sort. 
71
+    /// Crea los controles de la ventana secundaria. muestra la ventana secundaria 
72
+    /// y esconde la ventana principal.
73
+    void on_SortsButton_clicked();
69 74
 
70
-    void sorts();
75
+    /// \fn on_DiceButton_clicked
76
+    /// \~English
77
+    /// \brief Called when Dice button is clicked. Creates controls for secondary window,
78
+    /// displays it, and hides the main window.
79
+    /// \~Spanish
80
+    /// \brief Esta función es llamada cuando el usuario cliquea el boton de Dice. 
81
+    /// Crea los controles de la ventana secundaria. muestra la ventana secundaria 
82
+    /// y esconde la ventana principal.
83
+    void on_DiceButton_clicked();
71 84
 
72
-    void RPSs();
85
+    /// \fn on_RPSButton_clicked
86
+    /// \~English
87
+    /// \brief Called when RPS button is clicked. Creates controls for secondary window,
88
+    /// displays it, and hides the main window.
89
+    /// \~Spanish
90
+    /// \brief Esta función es llamada cuando el usuario cliquea el boton de RPS. 
91
+    /// Crea los controles de la ventana secundaria. muestra la ventana secundaria 
92
+    /// y esconde la ventana principal.  
93
+    void on_RPSButton_clicked();
73 94
 
74
-    void dices();
75 95
 
76
-    void checkWs();
96
+    /// \fn on_ZuluButton_clicked
97
+    /// \~English
98
+    /// \brief Called when Zulu time button is clicked. Creates controls for secondary window,
99
+    /// displays it, and hides the main window.
100
+    /// \~Spanish
101
+    /// \brief Esta función es llamada cuando el usuario cliquea el boton de Zulu time. 
102
+    /// Crea los controles de la ventana secundaria. muestra la ventana secundaria 
103
+    /// y esconde la ventana principal.  
104
+    void on_ZuluButton_clicked();
77 105
 
78
-    void zulus();
106
+    /// \fn showMW
107
+    /// \~English
108
+    /// \brief This function either (1) shows the main window and deletes all the items created on 
109
+    /// the closed one or (2) hides the mainwindow
110
+    /// \param doShow if true then show the main window, else hide it. 
111
+    /// \~Spanish
112
+    /// \brief Esta función hace una de dos: (1) muestra la ventana principal y borra
113
+    /// todas los elementos creados en la secundaria, o (2) esconde la ventana principal
114
+    /// \param doShow si es true muestra la ventana principal, de lo contrario la esconde. 
115
+    void showMW(bool doShow);
116
+
117
+
118
+    /// \fn setOption
119
+    /// \~English
120
+    /// \brief A slot that reads what item of the combo box was selected and saves it
121
+    /// to a data member.
122
+    /// \~Spanish
123
+    /// \brief Un slot que lee la selección del combobox y lo guarda a un data member.
124
+    void setOption(QString str);
125
+
126
+
127
+    /// \fn clearLines
128
+    /// \~English
129
+    /// \brief Clear the text boxes in the GUIs.
130
+    /// \~Spanish
131
+    /// \brief Limpia las cajas de texto en los GUIs.
132
+    void clearLines();
79 133
 
80
-    void APFTs();
134
+    /// \fn callOneOfTheSorts
135
+    /// \~English
136
+    /// \brief Reads the version combobox, validates the inputs, and calls the
137
+    /// alpha, beta, gamma or delta sort function.
138
+    /// \~Spanish
139
+    /// \brief Lee el combobox, valida los inputs y llama a la versión
140
+    /// alpha, beta, gamma o delta de las funciones de sort
141
+    void callOneOfTheSorts();
142
+
143
+
144
+    /// \fn callOneOfTheRPS
145
+    /// \~English
146
+    /// \brief Reads the version combobox, validates the inputs, and calls the
147
+    /// alpha, beta, gamma or delta RPS function.
148
+    /// \~Spanish
149
+    /// \brief Lee el combobox, valida los inputs y llama a la versión
150
+    /// alpha, beta, gamma o delta de las funciones de RPS (piedra, papel y tijera)
151
+    void callOneOfTheRPS();
152
+
153
+
154
+    /// \fn callOneOfTheDices
155
+    /// \~English
156
+    /// \brief Reads the version combobox, validates the inputs, and calls the
157
+    /// alpha, beta, gamma or delta dice function.
158
+    /// \~Spanish
159
+    /// \brief Lee el combobox, valida los inputs y llama a la versión
160
+    /// alpha, beta, gamma o delta de las funciones de "dice".
161
+    void callOneOfTheDices();
162
+
163
+
164
+    /// \fn callOneOfTheChecks
165
+    /// \~English
166
+    /// \brief Reads the version combobox, validates the inputs, and calls the
167
+    /// alpha, beta, gamma or delta check function
168
+    /// \~Spanish
169
+    /// \brief Lee el combobox, valida los inputs y llama a la versión
170
+    /// alpha, beta, gamma o delta de las funciones de cheques.
171
+    void callOneOfTheChecks();
172
+
173
+
174
+    /// \fn callOneOfTheZulus
175
+    /// \~English
176
+    /// \brief Reads the version combobox, validates the inputs, and calls the
177
+    /// alpha, beta, gamma or delta zulu time function
178
+    /// \~Spanish
179
+    /// \brief Lee el combobox, valida los inputs y llama a la versión
180
+    /// alpha, beta, gamma o delta de las funciones de zulu time.
181
+    void callOneOfTheZulus();
182
+
183
+
184
+    /// \fn paintDice
185
+    /// \~English
186
+    /// \brief This function is called on every timer tick to "animate" the dice.
187
+    /// \~Spanish
188
+    /// \brief Función invocada en cada tick del timer para "animar" el dado.
189
+    void paintDice();
81 190
 
82 191
 private:
83
-    Ui::MainWindow *ui;
84
-    secondwindow *window;
85
-    QGridLayout *layout;
86
-    QPushButton *button[2];
192
+    Ui::MainWindow  *ui;
193
+    secondwindow    *window;
194
+    QGridLayout     *layout;
195
+    QPushButton     *button[2];
196
+    QLineEdit       *line[7];
197
+    QLabel          *label[7];
198
+    QComboBox       *method, *cmbPlayer01, *cmbPlayer02;
199
+    QTimer          *aTimer;
200
+
87 201
     int buttonSize;
88
-    QLineEdit *line[7];
89 202
     int lineSize;
90
-    QLabel *label[7];
91 203
     int labelSize;
92
-    QComboBox *method;
93 204
     QString option;
94 205
     QImage dice1;
95 206
     QImage dice2;
207
+    int diceFinal01, diceFinal02;
208
+    int timerCounter;
96 209
     int score1, score2;
210
+
211
+    QVector<QImage> diceImages;
97 212
 };
98 213
 
99 214
 #endif // MAINWINDOW_H

+ 13
- 37
mainwindow.ui 파일 보기

@@ -6,8 +6,8 @@
6 6
    <rect>
7 7
     <x>0</x>
8 8
     <y>0</y>
9
-    <width>487</width>
10
-    <height>257</height>
9
+    <width>361</width>
10
+    <height>256</height>
11 11
    </rect>
12 12
   </property>
13 13
   <property name="sizePolicy">
@@ -42,8 +42,8 @@
42 42
    <widget class="QPushButton" name="RPSButton">
43 43
     <property name="geometry">
44 44
      <rect>
45
-      <x>330</x>
46
-      <y>70</y>
45
+      <x>10</x>
46
+      <y>140</y>
47 47
       <width>141</width>
48 48
       <height>61</height>
49 49
      </rect>
@@ -66,19 +66,6 @@
66 66
      <string>Dice</string>
67 67
     </property>
68 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 69
    <widget class="QPushButton" name="ZuluButton">
83 70
     <property name="geometry">
84 71
      <rect>
@@ -92,19 +79,6 @@
92 79
      <string>Zulu</string>
93 80
     </property>
94 81
    </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 82
    <widget class="QFrame" name="frame">
109 83
     <property name="geometry">
110 84
      <rect>
@@ -126,9 +100,9 @@
126 100
     <widget class="QLabel" name="label">
127 101
      <property name="geometry">
128 102
       <rect>
129
-       <x>180</x>
103
+       <x>30</x>
130 104
        <y>10</y>
131
-       <width>161</width>
105
+       <width>361</width>
132 106
        <height>41</height>
133 107
       </rect>
134 108
      </property>
@@ -143,6 +117,9 @@
143 117
      <property name="text">
144 118
       <string>Testing Lab</string>
145 119
      </property>
120
+     <property name="alignment">
121
+      <set>Qt::AlignCenter</set>
122
+     </property>
146 123
     </widget>
147 124
     <widget class="QFrame" name="frame_2">
148 125
      <property name="geometry">
@@ -150,7 +127,7 @@
150 127
        <x>30</x>
151 128
        <y>54</y>
152 129
        <width>641</width>
153
-       <height>21</height>
130
+       <height>16</height>
154 131
       </rect>
155 132
      </property>
156 133
      <property name="styleSheet">
@@ -163,13 +140,11 @@
163 140
       <enum>QFrame::Raised</enum>
164 141
      </property>
165 142
     </widget>
166
-    <zorder>frame_2</zorder>
167
-    <zorder>label</zorder>
168 143
    </widget>
169 144
    <widget class="QFrame" name="frame_3">
170 145
     <property name="geometry">
171 146
      <rect>
172
-      <x>290</x>
147
+      <x>160</x>
173 148
       <y>200</y>
174 149
       <width>201</width>
175 150
       <height>61</height>
@@ -179,11 +154,12 @@
179 154
      <string notr="true">background-image: url(:/images/resources/logo.png);</string>
180 155
     </property>
181 156
     <property name="frameShape">
182
-     <enum>QFrame::NoFrame</enum>
157
+     <enum>QFrame::StyledPanel</enum>
183 158
     </property>
184 159
     <property name="frameShadow">
185 160
      <enum>QFrame::Raised</enum>
186 161
     </property>
162
+    <zorder>label</zorder>
187 163
    </widget>
188 164
   </widget>
189 165
  </widget>

+ 1
- 1
secondwindow.cpp 파일 보기

@@ -7,5 +7,5 @@ secondwindow::secondwindow(QWidget *parent) :
7 7
 }
8 8
 
9 9
 void secondwindow::closeEvent(QCloseEvent *){
10
-    emit cerrado(true);
10
+    emit closeIt(true);
11 11
 }

+ 26
- 1
secondwindow.h 파일 보기

@@ -7,12 +7,37 @@ class secondwindow : public QWidget
7 7
 {
8 8
     Q_OBJECT
9 9
 public:
10
+
11
+    /// \fn secondwindow
12
+    /// \~English
13
+    /// \brief Constructor.
14
+    /// \param parent this object's parent
15
+    /// \~Spanish
16
+    /// \brief Constructor
17
+    /// \param parent ventana padre
10 18
     explicit secondwindow(QWidget *parent = 0);
11 19
 
12 20
 signals:
13
-    void cerrado(bool si);
21
+    /// \fn closeIt
22
+    /// \~English
23
+    /// \brief Just a signal that will be emitted when closing 
24
+	/// objects of this class
25
+	/// \param dummy this parameter is just for making this signal compatible with 
26
+    /// type of slot it will be connected.
27
+    /// \~Spanish
28
+    /// \brief Señal que será emitida al cerrar objetos de esta clase
29
+	/// \param dummy este parameterro existe para que la señal sea compatible con el
30
+	/// slot al que será conectada.
31
+    void closeIt(bool dummy);
14 32
 
15 33
 protected:
34
+
35
+    /// \fn closeEvent
36
+    /// \~English
37
+    /// \brief Overloaded function that is called when an object of this class is closed.
38
+    /// \~Spanish
39
+    /// \brief Función sobrecargada que es invocada cuando se cierra un objeto de 
40
+    /// esta clase.  
16 41
     virtual void closeEvent(QCloseEvent *);
17 42
 
18 43
 public slots: