#include <iostream>
#include <string>
using namespace std;
class SecureLogin {
private:
string ID;
string password;
int fail_count;
bool is_locked;
public:
SecureLogin(string id, string pw) {
ID = id;
password = pw;
fail_count = 0;
is_locked = false;
}
void login(string input_id, string input_pw) {
if (is_locked) {
cout << "접속 불가" << endl;
return;
}
if (ID != input_id || password != input_pw) {
fail_count++;
cout << "로그인 실패 [5회 로그인 실패시 계정 잠금("
<< (5 - fail_count) << "회 남음)]" << endl;
if (fail_count >= 5) {
is_locked = true;
cout << "계정 잠금" << endl;
}
} else {
cout << "로그인 성공" << endl;
fail_count = 0;
}
}
void reset_lock() {
fail_count = 0;
is_locked = false;
cout << "관리자에 의해 잠금 해제 완료" << endl;
}
};
int main() {
SecureLogin account("user01", "1234");
account.login("user01", "0000");
account.login("user01", "0000");
account.login("user01", "0000");
account.login("user01", "0000");
account.login("user01", "0000");
account.login("user01", "1234");
account.reset_lock();
account.login("user01", "1234");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: