1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
#include <string>
#include "User.h"
using namespace std;
int x;
user users[10] = { { 4, 55, true }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false }, { 4, 55, false } };
int hashCalc(string pass)
{
// check hash of every char in string //
for (int i = 0; i < pass.length(); i++)
{
// produce hash -96 from ascii to get place in alphabet //
x = x + (pass[i] - 96);
}
return x;
}
int main()
{
int attempts=0;
while (attempts < 3)
{
int userIn;
string passIn;
cout << "Username: ";
cin >> userIn;
cout << "Password: ";
cin >> passIn;
if (hashCalc(passIn) == users[userIn].getHash())
{
cout << "Login Success!!!" << endl;
cout << "User: " << userIn << endl;
cout << "Admin(y/n): " << users[userIn].getAdmin() << endl;
return 0;
}
else
{
cout << "Login fail try again. " << endl << endl;
attempts = attempts + 1;
}
}
cout << "GAME OVER MAN!" << endl;
}
|