소스 검색

Some minor fixes to the functions

부모
커밋
efa24a77f5
2개의 변경된 파일31개의 추가작업 그리고 12개의 파일을 삭제
  1. 28
    9
      functions.cpp
  2. 3
    3
      mainwindow.cpp

+ 28
- 9
functions.cpp 파일 보기

@@ -115,25 +115,23 @@ void mySortDelta(QString &a, QString &b, QString &c) {
115 115
 // Functions for the dice roller
116 116
 //========================================================
117 117
 
118
-//This is the correct dice roller
118
+#include <iostream>
119
+using namespace std;
119 120
 void MainWindow::diceAlpha(){
120 121
     int total = diceFinal01 + diceFinal02 + 2;
121 122
     line[0]->setText(QString::number(total));
122 123
 }
123 124
 
124
-//This version sums the first dice twice
125 125
 void MainWindow::diceBeta(){
126 126
     int total = diceFinal01 + diceFinal01 + 2;
127 127
     line[0]->setText(QString::number(total));
128 128
 }
129 129
 
130
-//This one substracts the second dice to the first one
131 130
 void MainWindow::diceGamma(){
132 131
     int total = diceFinal01 - diceFinal02;
133 132
     line[0]->setText(QString::number(total));
134 133
 }
135 134
 
136
-//This one takes the number 6 as a 12
137 135
 void MainWindow::diceDelta(){
138 136
     int total = diceFinal01 + diceFinal02;
139 137
     line[0]->setText(QString::number(total));
@@ -402,7 +400,10 @@ bool validZuluTime(const QString &time, const QString &zone, int &hours, int &mi
402 400
     if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59)
403 401
         return false;
404 402
 
405
-    if (zone.length() < 1 || !zone[0].isLetter()  || toupper(zone.toStdString()[0]) ==  'J') return false;
403
+    if (zone.length() < 1 || zone[0] < 'A' ||
404
+        zone[0] > 'Z'  || toupper(zone.toStdString()[0]) ==  'J')
405
+        return false;
406
+
406 407
     return true;
407 408
 }
408 409
 
@@ -437,7 +438,13 @@ QString zuluBeta(int hours, int minutes, char zone) {
437 438
 
438 439
     hours = (hours + (24 + diff) ) % 24;
439 440
 
440
-    return QString::number(hours)  + QString::number(minutes);
441
+    QString qstHours = QString::number(hours);
442
+    if (qstHours.length() == 1) qstHours.prepend("0");
443
+
444
+    QString qstMin = QString::number(minutes);
445
+    if (qstMin.length() == 1) qstMin.prepend("0");
446
+
447
+    return qstHours + qstMin;
441 448
 }
442 449
 
443 450
 QString zuluGamma(int hours, int minutes, char zone) {
@@ -448,9 +455,15 @@ QString zuluGamma(int hours, int minutes, char zone) {
448 455
     else if (zone <= 'Y')     diff = -(zone - 'N');
449 456
     else                      diff = 0;
450 457
 
451
-    hours = (hours + (24 - diff) ) % 24;
458
+    hours = (hours + (24 + diff) ) % 24;
452 459
 
453
-    return QString::number(hours) + QString::number(minutes);
460
+    QString qstHours = QString::number(hours);
461
+    if (qstHours.length() == 1) qstHours.prepend("0");
462
+
463
+    QString qstMin = QString::number(minutes);
464
+    if (qstMin.length() == 1) qstMin.prepend("0");
465
+
466
+    return qstHours + qstMin;
454 467
 }
455 468
 
456 469
 QString zuluDelta(int hours, int minutes, char zone) {
@@ -462,7 +475,13 @@ QString zuluDelta(int hours, int minutes, char zone) {
462 475
 
463 476
     hours = (hours + (24 - diff) ) % 24;
464 477
 
465
-    return QString::number(hours)  + QString::number(minutes);
478
+    QString qstHours = QString::number(hours);
479
+    if (qstHours.length() == 1) qstHours.prepend("0");
480
+
481
+    QString qstMin = QString::number(minutes);
482
+    if (qstMin.length() == 1) qstMin.prepend("0");
483
+
484
+    return qstHours + qstMin;
466 485
 }
467 486
 
468 487
 

+ 3
- 3
mainwindow.cpp 파일 보기

@@ -389,11 +389,11 @@ void MainWindow::paintDice() {
389 389
         diceFinal01 = a;
390 390
         diceFinal02 = b;
391 391
         if (option == "Version Alpha")
392
-            diceBeta();
392
+            diceAlpha();
393 393
         else if (option == "Version Beta")
394
-            diceGamma();
394
+            diceBeta();
395 395
         else if (option == "Version Gamma")
396
-            diceAlpha();
396
+            diceGamma();
397 397
         else
398 398
             diceAlpha();
399 399
     }