Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ATM  atm      = new ATM();
            bool loggedIn = false;

            Console.WriteLine("Welcome to the GC ATM");
            while (!loggedIn)
            {
                int input = Methods.CheckRange(Methods.GetUserInput("1. Login\n2. Register"), 1, 2);
                switch (input)
                {
                case 1:
                    atm.Login();
                    loggedIn = true;
                    break;

                case 2:
                    atm.Register();
                    break;
                }
            }
            bool furtherAction = true;

            while (furtherAction)
            {
                int input1 = Methods.CheckRange(Methods.GetUserInput("\n1. Check Balance\n2. Deposit\n3. Withdraw\n4. Log Out"), 1, 4);
                switch (input1)
                {
                case 1:
                    atm.CheckBalance();
                    break;

                case 2:
                    double deposit = Methods.CheckRange(Methods.GetUserInput("How much would you like to deposit? (minimum $5)"), 5, 100000);
                    atm.Deposit(deposit);
                    break;

                case 3:
                    double withdraw = Methods.CheckRange(Methods.GetUserInput("How much would you like to withdraw? (minimum $5 and max $10,000 per transaction)"), 5, 10000);
                    atm.Withdraw(withdraw);
                    break;

                case 4:
                    atm.LogOut();
                    Environment.Exit(0);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ATM atm            = new ATM();
            var currentAccount = new Account(null, null, 0);
            int userInputInt   = 0;

            do
            {
                Console.Clear();
                Console.WriteLine("Welcome to Grand Circus Bank!");
                Console.WriteLine();
                Console.WriteLine("[1] Log In");
                Console.WriteLine("[2] Create New Account");
                Console.WriteLine();
                Console.Write("Please Select One of the Above to Continue: ");
                string userInputString = Console.ReadLine();

                if (userInputString == "1")
                {
                    atm.Login(currentAccount);
                }
                else if (userInputString == "2")
                {
                    atm.Register();
                }
                else
                {
                    Console.WriteLine("Entry Not Recognized. Hit Enter to Continue.");
                    Console.ReadLine();
                    continue;
                }

                do
                {
                    Console.Clear();
                    Console.WriteLine("[1] Deposit Funds");
                    Console.WriteLine("[2] Withdraw Funds");
                    Console.WriteLine("[3] Check Balance");
                    Console.WriteLine("[4] Log Off");
                    Console.WriteLine();
                    Console.Write("Please Select One of the Above Options: ");
                    if (int.TryParse(Console.ReadLine(), out userInputInt) &&
                        userInputInt > 0 &&
                        userInputInt < 5)
                    {
                        switch (userInputInt)
                        {
                        case 1:
                        {
                            atm.Deposit(currentAccount.Balance);
                            break;
                        }

                        case 2:
                        {
                            atm.Withdraw(currentAccount.Balance);
                            break;
                        }

                        case 3:
                        {
                            atm.CheckBalance(currentAccount.Balance);
                            break;
                        }

                        case 4:
                        {
                            atm.Logout(currentAccount);
                            break;
                        }

                        default: break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input. Please Try Again. (Hit Enter to Continue)");
                        Console.ReadLine();
                    }
                } while (userInputInt != 4);
            } while (true);
        }