adding member
Dependencies: TextLCD
Diff: main.cpp
- Revision:
- 2:397be4b2e023
- Parent:
- 1:028c44d2aa6d
- Child:
- 3:be0b871f3ff9
--- a/main.cpp Wed Mar 18 14:05:33 2020 +0000 +++ b/main.cpp Wed Mar 18 14:58:47 2020 +0000 @@ -44,70 +44,77 @@ } - lcd.printf("Welcome, Select password"); - wait(1); - lcd.cls(); + + int check = 1; + while(check) { + lcd.printf("Welcome, Select password"); + wait(1); + lcd.cls(); - int count; - for (count = 0; count < 10; count++) { - if(password.size() < 4) { + int count; + for (count = 0; count < 10; count++) { + if(password.size() < 4) { - lcd.printf("Select Number : %i",count); - wait(1); - lcd.cls(); - - - if (debug1 > 1) { - std::cout << "Select Number : " << count << " ?\n" << std::endl; - scanf("%s", &str1); - } - - if (acceptbutton == 0) { //RD2 (the button configurations for RD0 will be here) - password.push_back(count); - //std::cout << password[(password.size() - 1)] << std::endl; - count = -1; - } else if (incrementbutton == 0) { //incrementing //RD0 (the button configurations for RD1 will be here) - continue; - } else if (decrementbutton == 0) { //RD1 (the button configurations for RD2 will be here) - count--; - count--; - } else { - lcd.printf("INValid Selection"); + lcd.printf("Select Number : %i",count); wait(1); lcd.cls(); + if (debug1 > 1) { - std::cout << "Enter A Valid Selection\n" << std::endl; + std::cout << "Select Number : " << count << " ?\n" << std::endl; + scanf("%s", &str1); } - } - } - } + if (acceptbutton == 0) { //RD2 (the button configurations for RD0 will be here) + password.push_back(count); + //std::cout << password[(password.size() - 1)] << std::endl; + count = -1; + } else if (incrementbutton == 0) { //incrementing //RD0 (the button configurations for RD1 will be here) + continue; + } else if (decrementbutton == 0) { //RD1 (the button configurations for RD2 will be here) + count--; + count--; + } else { + lcd.printf("INValid Selection"); + wait(1); + lcd.cls(); - std::copy(password.begin(),password.end(),std::ostream_iterator<int>(oss)); - - std::string result = oss.str(); - const char *c_result = result.c_str(); + if (debug1 > 1) { + std::cout << "Enter A Valid Selection\n" << std::endl; + } + } - if(!strcmp(c_result,Attendant1.systemPassword)) { - lcd.printf("%s", c_result); - lcd.printf("\n"); - wait(1); - lcd.cls(); - } else { - // std::cout << "password incorrect\n" << "Try Again" << std::endl; + } + } + + std::copy(password.begin(),password.end(),std::ostream_iterator<int>(oss)); + + std::string result = oss.str(); + const char *c_result = result.c_str(); - lcd.printf("incorrect Try Again""); - wait(1); - lcd.cls(); + if(!strcmp(c_result,Attendant1.systemPassword)) { + lcd.printf("%s", c_result); + lcd.printf("\n"); + wait(1); + lcd.cls(); + check = 0; + } else { + // std::cout << "password incorrect\n" << "Try Again" << std::endl; + + lcd.printf("incorrect Try Again""); + wait(1); + lcd.cls(); + password.clear(); + } + + } - password.clear(); return 0; };