Exemple #1
0
        public static void Main()
        {
            ATM a = new ATM();

SUDO_MAIN:  // from MAIN MENUS logic // to avoid re-initilialize ATM class!!
            int getAtm_no = 0;

            UI_home();                                         // Homepage
                                                               // Login Page logic - Do not mess it up!!
LOGIN:
            int isValidLogin = UI_login(ref a, ref getAtm_no); // calls login UI which return integers

            switch (isValidLogin)
            {
            case -1:
                UI_error("Alphabets Not Allowed");
                goto LOGIN;

            case 1:
                goto MAIN_MENU;     // Goto Main Menus if valid user

            case 2:
                UI_error("Invalid Password");
                goto LOGIN;

            case 3:
                UI_error("Invalid Account Number");
                goto LOGIN;

            default:
                UI_error("Something Wrong in GUI_login()!");
                Main();
                break;
            }


            //MAIN MENUS logic
MAIN:
MAIN_MENU:  // from Login Page
            while (true)
            {
                mnuChoice = UI_main(ref getAtm_no); // call MAIN_UI
                switch (mnuChoice)
                {
                case -1:
                    UI_error("Alphabets Not Allowed");
                    goto MAIN;

                case 1:
                    a.deposit(getAtm_no);
                    break;

                case 2:
                    a.withdraw(getAtm_no);
                    break;

                case 3:
                    a.balance(getAtm_no);
                    break;

                case 4:
                    a.tnfr_fund(getAtm_no);
                    break;

                case 5:
                    a.mini_stmt(getAtm_no, false);     //false for full n no.of tranx recordings
                    break;

                case 6:
                    a.chng_pin(getAtm_no);
                    break;

                case 7:
                    a.mini_stmt(getAtm_no, true);     //true for last 5 noof tranx recordings
                    break;

                case 8:
                    UI_msgbox("Thankyou for visting T6G ATM.\n");
                    GC.SuppressFinalize(a);    //Garbage Collection
                    goto SUDO_MAIN;

                default:
                    UI_error("Invalid Choice! [1-8].");
                    Main();
                    break;
                }
            }
        }
Exemple #2
0
        public static int UI_login(ref ATM u, ref int atm_no)
        {
            header();
            Console.Write(st + "Enter your CARD no: ");
            try
            {
                bool check    = false;
                int  i        = 0;
                int  atm_numb = int.Parse(Console.ReadLine());
                atm_no = atm_numb;


                for (int j = 0; j < u.usr.Length; j++)
                {
                    if (u.usr[j].atm_no == atm_numb) // valid acc_no
                    {
                        check = true;
                        i     = j;
                    }
                }

                if (check) // valid acc_no
                {
                    Console.Write(st + "Enter your PIN: ");
                    string         acc_pin = "";;
                    ConsoleKeyInfo key;

                    do
                    {
                        key = Console.ReadKey(true);

                        // Backspace Should Not Work
                        if (key.Key != ConsoleKey.Backspace)
                        {
                            acc_pin += key.KeyChar;
                            Console.Write("*");
                        }
                        else
                        {
                            if ((acc_pin.Length - 1) != -1)
                            {
                                acc_pin = acc_pin.Remove(acc_pin.Length - 1);
                                Console.Write("\b \b");
                            }
                        }
                    } // Stops Receving Keys Once Enter is Pressed
                    while (key.Key != ConsoleKey.Enter);



                    if ((u.usr[i].usrPin == int.Parse(acc_pin)) && (u.usr[i].atm_no == atm_numb)) // valid acc_no && pass
                    {
                        return(1);                                                                // 1: means successfull
                    }
                    else
                    {
                        // Boot out usr if exceeded Trails == 3
                        u.usr[i].usrMaxTrail = count++;

                        if (u.usr[i].usrMaxTrail >= 2)
                        {
                            count = 0;
                            UI_error("Reached Maxed Limit of Trying");
                            Main();
                        }
                        else
                        {
                            //< 3 trials but invalid password
                            return(2);
                        }
                    }
                }
                else // Invalid account number
                {
                    return(3);
                }
            }
            catch (Exception)
            {
                return(-1);
            }
            // defualt : false
            return(0);
        }