Advertisement
Guest User

Help needed

a guest
Feb 5th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. class req
  8. {
  9.  
  10.  
  11. public:
  12.     string username;
  13.     string password;
  14.  
  15.     string getUn()
  16.     {
  17.         return username;
  18.     }
  19.     void setUn(string username)
  20.     {
  21.         this->username = username;
  22.     }
  23.  
  24.     string getPw()
  25.     {
  26.         return password;
  27.     }
  28.     void setPw(string password)
  29.     {
  30.         this->password = password;
  31.     }
  32.  
  33.     void enterName()
  34.     {
  35.         string un;
  36.         cout << "Username: ";
  37.         cin >> un;
  38.         if(un == username)
  39.         {
  40.             enterPassword();
  41.         }
  42.         else if (un != username)
  43.         {
  44.             cout << "wrong, try again!" << endl;
  45.             enterName();
  46.         }
  47.     }
  48.  
  49.     void enterPassword()
  50.     {
  51.         string pw;
  52.         cout << "Password: ";
  53.         cin >> pw;
  54.  
  55.         if(pw == password)
  56.         {
  57.             cout << ", Good to go!";
  58.         }
  59.         else if (pw != password)
  60.         {
  61.             cout << "wrong, try again!" << endl;
  62.             enterPassword();
  63.         }
  64.     }
  65.  
  66. };
  67.  
  68.  
  69.  
  70. int main()
  71. {
  72.     req myself;
  73.     myself.setUn("self");
  74.     myself.setPw("idklol");
  75.  
  76.     req oof;
  77.     oof.enterName();
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement