#include <iostream>
#include <string>
#include <cctype>
using namespace std;

class User {
private:
    string ID;
    string password;
public:
    User(string ID, string password){
        this->ID = ID;            
        this->password = password;
    }

    void set_password(const string &new_pw) {
        if (new_pw.length() < 8) {
            cout << "설정 실패" << endl;
            return;
        }

        bool hasNumber = false;
        for (char c : new_pw) {
            if (isdigit(c)) {
                hasNumber = true;
                break;
            }
        }

        if (!hasNumber) {   // False → false
            cout << "설정 실패" << endl;
            return;
        }

        password = new_pw;
        cout << "비밀번호 설정 완료" << endl;
    }

    bool check_login(const string &input_id, const string &input_pw) {
        return (input_id == ID && input_pw == password); 
    }
};

int main(){
    User user("user01","abcd1234");

    user.set_password("abc12");
    user.set_password("abcd1234");

    if (user.check_login("user01", "abcd1234")) {
        cout << "로그인 성공" << endl;
    } else {
        cout << "로그인 실패" << endl;
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: