コード例 #1
0
        //First menu user encounters, where he can creat a new account or choose an existing one.
        public void AccountCreationMenu()
        {
            while (!exit)
            {
                Console.Clear();
                Console.WriteLine("Choose action:");
                Console.WriteLine("1) Login to existing account.  2) Create new acount.  3) Exit aplication.\n");
                Console.WriteLine();
                Console.WriteLine(errorMessage);

                try
                {
                    switch (Console.ReadLine())
                    {
                    case "1":
                    {
                        Console.WriteLine("Please select account ID.");
                        try
                        {
                            int     index          = UserIDInput();
                            Account currentAccount = AccountFactory.accountData[index];
                            MainAccountMenu(currentAccount);
                        }
                        catch (ArgumentException)
                        {
                            AccountCreationMenu();
                        }
                        break;
                    }

                    case "2":
                    {
                        Console.WriteLine("How much would you like to initially deposite?");
                        AccountFactory.CreatAccount(UserMoneyInput());
                        Account currentAccount = AccountFactory.accountData[AccountFactory.accountData.Count - 1];
                        MainAccountMenu(currentAccount);
                        break;
                    }

                    case "3":
                    {
                        exit = true;
                        back = true;
                        Console.WriteLine("Thank you for using E-Bank! Goodbye!");
                        break;
                    }

                    default:
                    {
                        errorMessage = "Error: invalid opperation. Pleae choose a number between (1-3).";
                        break;
                    }
                    }
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    errorMessage = string.Format("Error: {0}", ex);
                }
                catch (InsufficientFundsException ex)
                {
                    errorMessage = string.Format("Error: {0}", ex);
                }
                catch (ArgumentException ex)
                {
                    errorMessage = string.Format("Error: {0}", ex.Message);
                }
            }
        }