如何重用功能?

时间:2015-12-12 10:25:10

标签: c++

预先警告:你正在与那些对C ++编程经验很少的人打交道。

您好。

基本上,我正在将ATM程序作为我们主题的一部分。除了更改PIN功能外,我获得了大部分核心ATM内容(余额查询,提款,存款)。

以下是更好理解的大纲: PIN Change Outline

我一直到改变我的Pin部分,之后,如果我做了一个新的PIN输入代码,如果完成后重新指向主菜单,那么我什么也没有得到任何问题。某个错误是“重新定义函数”错误,它只是说程序上的所有函数都已在其他地方定义。

问题是:在我更改PIN码后,我将如何继续?

编辑:顺便说一句,“更改PIN码”代码是:

#include <iostream>
#include <conio.h>
#include <string.h>
#include "GlobalResources.h"
#include "delay_7.cpp"
#include "DeadEnd_2.cpp"
#include "PIN_2.cpp"

using namespace std;

main()
{
        int x, y, z, count = 1, NewCount = 1;
        char Decision, Y, N;
        char TempPIN1[5], TempPIN2[5];
        ReChange:
        system ("cls");
        cout << "WARNING! This process is irreversible! Do you still want to continue? (Y/N) ";
        Decision = toupper (getch());
        if (Decision == 'Y')
        {
                ReTry:
                system ("cls");
                cout << "Enter your PIN Code: " << endl;
                for (x = 0; x <= 4; x++)
                {
                    TempPIN1[x] = getch();
                    putch ('*');
            }

            PIN[5] = '\0';

            NewPass:
            if (strcmp (TempPIN1, "12345") == 0)
            {
                cout << endl << "Enter your new password: ";
                for (y = 0; y <= 4; y++)
                {
                    NewPIN[y] = getch();
                    putch ('*');
                }

                NewPIN[5] = '\0';

                cout << endl << "Enter the new password again: ";
                for (z = 0; z <= 4; z++)
                {
                    TempPIN2[z] = getch();
                    putch ('*');
                }

                TempPIN2[5] = '\0';

                if (strcmp (NewPIN, TempPIN2) == 0)
                {
                    strcpy (NewPIN, PIN);
                    cout << endl << "PIN Code has been changed. " << endl;
                    delaychangepin();
                    **//AFTER THIS, I'M SUPPOSED TO ENTER THE NEW PIN**
                }

                else
                {
                    cout << endl << "New password does not match!" << endl;
                    goto NewPass;
                }

            }

            else
            {
                count = count + 1;

                if (count <= 3)
            {
                system ("cls");
                cout << "INVALID PIN CODE! PLEASE TRY AGAIN!" << endl;
                delaychangepin();
                goto ReTry;
            }

            else
            {
            DeadEnd2();
            }
    }
    }

    else if (Decision == 'N')
    {

    }

    else
    {

        cout <<  endl << "Invalid Decision Response!" << endl;
        delaychangepin();
        goto ReChange;
    }

}

0 个答案:

没有答案