首页 > 解决方案 > 密码 While 循环

问题描述

我需要有关更改密码的帮助。这是项目的界面打开并重新打开时的部分。

int main()
{
    Padlock Lock;

    int D = 0;
    int m = 1;

    Lock.type_keycode();

    do {

        Lock.type_keycode1();

        Lock.set_password(Lock.get_keycode());
        Lock.set_userinput(Lock.get_keycode1());

        Lock.Lockopen(Lock.get_password(), Lock.get_userinput());

        cout << "TEST " << endl;
        if (Lock.get_password() == Lock.get_userinput()) {

            Lock.Lockoption(Lock.get_password(), Lock.get_userinput());
        }

    } while (Lock.get_keycode() != D);

    return 0;
}

一旦 switch 语句打开,它就会执行这个命令。这是 switch 语句变量打开插槽并且您也希望它更改密码的部分。每次输出它都不会更改密码。

void Padlock::Lockoption(int password, int userinput)
{

    int option;
    int answer;
    Padlock Lock;

    do {

        cout << "Choose your option: " << endl;
        cout << endl
             << "0 - Reset Passwod. ";
        cout << endl
             << "1 - Change Battery. ";
        cout << endl
             << "2 - Return to Menu. ";
        cout << endl
             << "3 - Defualt";
        cout << endl
             << "4 - EXIT \n";

        cout << "ENTER 0-4: " << endl;
        cin >> option;
        cout << endl;

        switch (option) {
        case 0:
            cout << "Enter the three digits to reset Password: " << endl;
            cin >> password;
            Lock.set_password(password);
                                                          #Sets the password
                Lock.get_password();
                                                      #password is encrypted
                Lock.set_encrypted(password);
                                                      #Password is confirmed
                Lock.get_encrypted();
                                                     #encrypted is confirmed
                    cout
                << endl;
            cout << m << endl;
            break;

当它被调试时,你输入新密码。但是,当您使用它时,它不起作用。

标签: c++while-loop

解决方案


推荐阅读