Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <conio.h>
  4.  
  5. //MY FIRST COMMENT YEEEEEEEEEEEEEEEEEEEEE
  6. using namespace std;
  7.  
  8. class UserData
  9. {
  10.     protected:
  11.         string username;
  12.         string password;
  13.  
  14.     public:
  15.         bool check(string user, string pass)
  16.         {
  17.             if (user==username && pass==password)
  18.                 return true;
  19.             else
  20.                 return false;
  21.         }
  22.         void setData(string user, string pass)
  23.         {
  24.             username = user;
  25.             password = pass;
  26.         }
  27. };
  28.  
  29. int main()
  30. {
  31.     //cout << "message";            //output
  32.     //cin >> var;                   //input
  33.     //_getch();                     //wait for message
  34.     string user, pass;
  35.  
  36.     UserData users[5];
  37.     for(int i=0;i<5;i++)
  38.     {
  39.  
  40.         cout << "Please enter a new username:" << endl;
  41.         cin >> user;
  42.         cout << "Please enter a password for that user:" << endl;
  43.         cin >> pass;
  44.         users[i].setData(user,pass);
  45.     }
  46.     system("cls");
  47.     cout << "5 Users have been created." << endl;
  48.  
  49.     while (true)
  50.     {
  51.         cout << "Please enter a username:" << endl;
  52.         cin >> user;
  53.         cout << "Please enter the password for that user:" << endl;
  54.         cin >> pass;
  55.         for(int i=0;i<5;i++)
  56.         {
  57.             if (users[i].check(user,pass) == true)
  58.             {
  59.                 cout << "User logged in successfully." << endl;
  60.                 break;
  61.             }
  62.             if (i == 4)
  63.                 cout << "Username and Password do not match anything in our database." << endl;
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement