#include <iostream>
#include <string>
#include <fstream>
using namespace std;
ifstream FIn_Login;
ofstream FOut_Login;
ifstream FIn_Password;
ofstream FOut_Password;
enum Check
{
Login = 1,
Password = 2
};
class Person
{
public:
void Login();
void Register();
bool Check(string word, int a);
int unitForLogin = 0;
int unitForPassWord = 0;
private:
string login;
string firstPassword;
string secondPassword;
};
void Menu();
int main()
{
Menu();
FIn_Login.close();
FOut_Login.close();
FIn_Password.close();
FOut_Password.close();
}
void Person::Login()
{
cout << "Insert Login :";
cin >> login;
if (Check(login, Check::Login))
{
cout << "Insert Password :";
cin >> firstPassword;
if (Check(firstPassword, Check::Password))
{
cout << "Correct.";
}
else
{
cout << "Incorrect.";
}
}
else
{
cout << "Wrong login.";
}
}
void Person::Register()
{
cout << "Insert Login :";
cin >> login;
cout << "Insert Password :";
cin >> firstPassword;
cout << "Insert Password again :";
cin >> secondPassword;
if (Check(login, Check::Login))
{
cout << "Login is Taken" << endl;
Register();
}
else if (!Check(login, Check::Login))
{
if (firstPassword == secondPassword)
{
cout << endl << "Successful Register.";
FOut_Login << login << endl;
FOut_Password << firstPassword << endl;
}
else
{
cout << "Password is not the same.";
}
}
}
void Menu()
{
FIn_Login.open("Login.txt", ios::app);
FIn_Password.open("Password.txt", ios::app);
FOut_Login.open("Login.txt", ios::app);
FOut_Password.open("Password.txt", ios::app);
if (FOut_Login.is_open() && FOut_Password.is_open())
{
cout << "File is Open" << endl;
}
else
{
cout << "File is Not Open" << endl;
}
Person ObjPerson;
int i;
cout << "Choice Options :" << endl;
cout << "1. Login." << endl;
cout << "2. Register." << endl;
cin >> i;
system("CLS");
if (i == 1)
{
ObjPerson.Login();
}
else if (i == 2)
{
ObjPerson.Register();
}
else
{
cout << "ERROR!" << endl;
}
}
bool Person::Check(string word, int a)
{
string msg = "";
bool checking = false;
if (Check::Login)
{
while (!FIn_Login.eof())
{
string msg = "";
FIn_Login >> msg;
if (msg == word)
{
checking = true;
break;
}
else
{
checking = false;
}
}
}
else if (Check::Password)
{
while (!FIn_Password.eof())
{
string msg = "";
FIn_Password >> msg;
if (msg == word)
{
checking = true;
break;
}
else
{
checking = false;
}
}
}
return checking;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}