Pair programming: small high early math learning software with the UI (aloof C ++ version)

The pair programming aimed at achieving an early small high math learning software with UI, there is an increase in the basis of the original functions of individual projects:

  1. Implementation of the registration, log function, save user data
  2. Users can modify the password
  3. Users do question during a question a question topic and there are four options appear
  4. The system according to user needs to do question the correctness of the score is given
  5. Software to bring UI

First, construct a UI interface qt

  Because we use C ++ as a language to complete this project, do interface with qt on the recommendation of seniors. Because the interface is not done before, nor used qt, qt so spent a lot of time to get started. The first day saw a video tutorial to see qt autistic because of too detailed tutorial b station, did not have time to read all, dancing and watching of focus, so watched a few episodes will try to take up the interface. Prior to this step, I recommend the software to interface processes planned and then built up one by one interface. Here is more ignorant forced Beginners places:

  • The interface between the jump, the signal is achieved by the groove.
  • Interface key functions to achieve, you can select the control in the "Design" screen and then right "to slot" to fill the slot function implementation.
  • Later, when optimized interface found qt actually have qss, just like css about it, we can directly in the "Design" interface, rewritten style sheets, the format is almost exactly the same with css
  • It will run in the background when the screen interface to insert background image is not displayed, and the impact of the background controls, if this is not recommended to add a background in design interface, you can add the following code to interface cpp constructor:
    Image1 the QImage; 
    image1.load ( "../ myItem / sub BACKGROUND .png" ); 
    the QImage image2 = image1.scaled (911,577 ); 
    setAutoFillBackground (to true );  QPalette PAL = this-> Palette ();  // pal.setColor (QPalette :: image, QColor (19 , 54, 118)); this is the background color pal.setBrush (backgroundRole (), QBrush ( image2)); setPalette (pal);

Second, the formula to calculate the correct answer, and scored

In the individual event, not as long as the formula to calculate the correct answer, but this knot correct answer results of the program need to score so it is necessary to calculate.

We are the first middle school formulas '^ 2' '^ 1 / 2''sin' like the first calculation is completed, then the four arithmetic operations, wherein the four arithmetic operations using infix expressions do online operation, attached four operations Code (calculated brackets case, decimal, negative)

  #Include. 1 "tcal.h" 
  2 #include <bits / STDC ++. H> 
  . 3 #include <QString> 
  . 4 #include <QChar> 
  . 5 #include <the QByteArray> 
  . 6 #include <QDebug> 
  . 7 #include <qmath.h> 
  the using namespace. 8 STD; 
  . 9 extern QString S; 
 10 extern Double TResult; 
 . 11 Stack <Double> Val;  12 is Stack <char> Symbol;  13 is the QByteArray byte ; 14 tcal :: tcal () 15 {16. 17 }. 19 tcal 18 is :: ~ tcal () 20 is {21 is 22 is a priority comparison between the operator // 23} char tcal :: CMP 24 (a char, char B) {// right bracket 25 will not enter the stack, without having to write the right parenthesis 26 // encountered priority right parenthesis to pop up left parenthesis 27 if (a == '#'){ 28 if(b=='#'){ 29 return '='; 30 }else{ 31 return '<'; 32  } 33  } 34 if(a=='+'||a=='-'){ 35 if(b=='*'||b=='/'||b=='('){ 36 return '<'; 37 }else{ 38 return '>'; 39  } 40  } 41 if(a=='*'||a=='/'){ 42 if(b=='('){ 43 return '<'; 44 }else{ 45 return '>'; 46  } 47  } 48 if(a=='('){ 49 if(b==')'){ 50 return '='; 51 }else{ 52 return '<'; 53  } 54  } 55 } 56 //返回计算结果 57 double tcal::cal_t(double a,double b,char op){ 58 switch(op){ 59 case '+': 60 return a+B; Case 61 is '-' : return 62 is A- B; Case 63 is '*' : A * 64 return B; Case 65 '/' : return 66 A / B; 67 } 68 during evaluation of the expression // 69} void 70 tcal :: Process () {71 is symbol.push ( '#' ); I = 0 uint 72 ; 73 is Double NUM = 0.0 ; 74 char * C; BA = 75 the QByteArray s.toLatin1 (); C = 76 BA .data (); // get the character FF int = 0 77 ; 78 the while (symbol.top () = '#' || I <! {IF 79 (C [I] == '- s.size ()) ' ) 80 {FF = 81. 1 ; 82 ++ I; 83 } 84 the else IF (C [I]> =' 0 '&& C [I] <='. 9 ' ) {85 // operand 86 num = 0 ; 87 F int = 0 ; 88 the while ((C [I]> = '0') && (C [I] <= '. 9')||(c[i]=='.')){ 89 if((i == 0)&&c[i]=='-') 90  { 91 ff = 1; 92  } 93 else if((c[i]=='.')||(f != 0)) 94  { 95 if(c[i]!='.') 96  { 97 num*=10; 98 num+=c[i]-'0'; 99 f++; 100 ++i; 101  } 102 else 103  { 104 ++i; 105 f++; 106  } 107  } 108 else 109  { 110 num*=10; 111 num+=c[i]-'0'; 112 ++i; 113  } 114  } 115 if(ff == 1) 116  { 117 num = num*(-1); 118  } 119 ff = 0; 120 if(f!=0) 121 num = num/pow(10,f-1); 122  val.push(num); 123 //cout<<"num="<<num<<endl; 124  } 125 else 126  { 127 switch(cmp(symbol.top(),c[i])){ 128 case '<': 129  symbol.push(c[i]); 130 ++i; 131 break; 132 case '=': 133  symbol.pop(); 134 ++i; 135 break; 136 case '>': 137 double a=val.top(); 138  val.pop(); 139 double b=val.top(); 140  val.pop(); 141  val.push(cal_t(b,a,symbol.top())); 142 //cout<<"a="<<a<<" "<<"b="<<b<<endl; 143 //cout<<"num="<<val.top()<<endl; 144  symbol.pop(); 145 break; 146  } 147  } 148  } 149 double res=val.top(); 150  val.pop(); 151 Tresult = res; 152 return; 153 154 }

Third, SMS verification

Do not ask, ask C ++ is so poor ...... we implement the interface using java, c ++ call java executables and phone number to send a verification code to the platform. Here is Ali cloud messaging service, Tencent signature verification more stringent.

Fourth, personal experience

This project down, code, and greatly enhance the ability of Cultivation, finally did one day from morning to learn later, as if to return to high school. Or done great sense of accomplishment, but also to know myself a lot of features to achieve did not imagine the complex. In addition, there is little sentiment, knocking the code really is the easiest thing a focus

Guess you like

Origin www.cnblogs.com/neti/p/11605053.html