コード例 #1
0
        public static void menu(Client myCustomer) // MAIN MENU - BACK END
        {
            int choice = 0;

            // infinite loop with a break point.
            while (true)
            {
                // displays the menu
                int all = myCustomer.allAccounts.Count;
                Client.makeChoice(ref choice, myCustomer.name);

                if (choice == 1)
                {
                    string type = Account.selectType();
                    header();
                    myCustomer.OpenAccount(type);
                    saveToFile(myCustomer);
                    continueOrExit(myCustomer.name);
                }
                else if (choice == 2)
                {
                    if (all == 0)
                    {
                        myCustomer.noAccounts();
                    }
                    else
                    {
                        int index = myCustomer.select("close");
                        myCustomer.CloseAccount(index);
                    }
                }
                else if (choice == 3) // LIST ALL ACCOUNTS
                {
                    header();
                    if (all == 0)
                    {
                        myCustomer.noAccounts();
                    }
                    else
                    {
                        myCustomer.listOpen();
                        saveToFile(myCustomer);
                        continueOrExit(myCustomer.name);
                    }
                }
                else if (choice == 4)
                {
                    if (all == 0)
                    {
                        myCustomer.noAccounts();
                    }
                    else
                    {
                        int deposit        = 0;
                        int indexToDeposit = myCustomer.selectAndDeposit(out deposit);
                        myCustomer.Deposit(indexToDeposit, deposit);
                    }
                }
                else if (choice == 5)
                {
                    if (all == 0)
                    {
                        myCustomer.noAccounts();
                    }
                    else
                    {
                        int withdraw       = 0;
                        int indexToDeposit = myCustomer.selectAndWithdraw(out withdraw);
                        withdraw = -withdraw;
                        myCustomer.Deposit(indexToDeposit, withdraw);
                    }
                }
                else if (choice == 6)
                {
                    if (all == 0)
                    {
                        myCustomer.noAccounts();
                    }
                    else
                    {
                        int index = myCustomer.select("get information for");
                        myCustomer.allAccounts[index - 1].PrintInfo();
                    }
                }
                else
                {
                    saveToFile(myCustomer);
                    Client.thankYou();
                    break;
                }
            }
        }