Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <conio.h>
- //MY FIRST COMMENT YEEEEEEEEEEEEEEEEEEEEE
- using namespace std;
- class UserData
- {
- protected:
- string username;
- string password;
- public:
- bool check(string user, string pass)
- {
- if (user==username && pass==password)
- return true;
- else
- return false;
- }
- void setData(string user, string pass)
- {
- username = user;
- password = pass;
- }
- };
- int main()
- {
- //cout << "message"; //output
- //cin >> var; //input
- //_getch(); //wait for message
- string user, pass;
- UserData users[5];
- for(int i=0;i<5;i++)
- {
- cout << "Please enter a new username:" << endl;
- cin >> user;
- cout << "Please enter a password for that user:" << endl;
- cin >> pass;
- users[i].setData(user,pass);
- }
- system("cls");
- cout << "5 Users have been created." << endl;
- while (true)
- {
- cout << "Please enter a username:" << endl;
- cin >> user;
- cout << "Please enter the password for that user:" << endl;
- cin >> pass;
- for(int i=0;i<5;i++)
- {
- if (users[i].check(user,pass) == true)
- {
- cout << "User logged in successfully." << endl;
- break;
- }
- if (i == 4)
- cout << "Username and Password do not match anything in our database." << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement