#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class Server {
public:
bool IsOverlapped(const string &id);
};
class Account {
private:
Server server;
string id = "myID";
string password = "myPW";
public:
void SetServer(Server &server);
bool Set(const string &id, const string &pw);
bool QueryLog(const string &id, const string &pw);
};
int main()
{
Server server;
Account acc;
acc.SetServer(server);
if (!acc.Set("myID", "myPW")) {
cout << "ID가 중복되었습니다. " << endl;
}
if (acc.QueryLog("myID", "myPW"))
{
cout << "로그인에 성공하였습니다. " << endl;
}
return 0;
}
bool Account::QueryLog(const string &id, const string &pw)
{
return this->id == id && this->password == pw;
}
bool Account::Set(const string &id, const string &pw)
{
if (server.IsOverlapped(id))
{
return false;
}
this->id = id;
this->password = pw;
return true;
}