Example #1
0
        static void Main(string[] args)
        {
            Client          client = new Client("Gerald Garner", "100100100", "100100101");   //instantiate a Client object
            CheckingAccount clientCheckingAccount = new CheckingAccount("100100100", 10000);  //instantiate a CheckingAccount object
            SavingsAccount  clientSavingsAccount  = new SavingsAccount("100100101", 1000000); //instantiate a SavingsAccount object

            int     userInput;
            string  accountChoice;
            decimal amount;

            //print menu
            Console.WriteLine("Welcome to the Bank\n\nMenu:\n\n1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit");

            //allow user to continue making selections until they enter "5" (exit)
            do
            {
                Console.WriteLine("\nEnter a selection 1-5 from the menu above");
                Int32.TryParse(Console.ReadLine(), out userInput);

                switch (userInput)
                {
                case 1:     //client info
                    Console.WriteLine("\n" + client.ListClientInformation());
                    break;

                case 2:     //account balance
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a")
                    {
                        clientCheckingAccount.DisplayAccountBalance();
                    }
                    else
                    {
                        clientSavingsAccount.DisplayAccountBalance();
                    }
                    break;

                case 3:                       //deposit funds
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a") //checking
                    {
                        amount = GetAmount();
                        clientCheckingAccount.DepositMoney(amount);
                    }
                    else     //savings
                    {
                        amount = GetAmount();
                        clientSavingsAccount.DepositMoney(amount);
                    }

                    break;

                case 4:                       //withdraw funds
                    accountChoice = GetAccountChoice();
                    if (accountChoice == "a") //checking
                    {
                        amount = GetAmount();
                        clientCheckingAccount.WithdrawMoney(amount);
                    }
                    else     //savings
                    {
                        amount = GetAmount();
                        clientSavingsAccount.WithdrawMoney(amount);
                    }
                    break;

                case 5:     //exit
                    Console.WriteLine("Have a nice day!");
                    break;

                default:     //if user does not enter 1-5, they will be reminded to do so and loop will run again
                    Console.WriteLine("You must select a number 1-5");
                    break;
                }
            }while (userInput != 5);
        }
Example #2
0
        static void Main(string[] args)
        {
            //public static void getMenu()


            Client          newClient   = new Client("Tyler", "Graves", "July 26 1990", "1426 Imaginary Ave", "135-79-2468");
            CheckingAccount newChecking = new CheckingAccount();
            SavingsAccount  newSaving   = new SavingsAccount(150);



            Console.WriteLine("Hello, welcome to the big bank of code!");
            Console.WriteLine();
            Console.WriteLine("Please select a number based on the following options");

            string menuFunctions = "1,2,3,4,5";

            do
            {
                Console.WriteLine("1. View client information \n 2. View account balance \n 3. Deposit funds \n 4. Withdraw funds \n  5. Exit");
                string menuSelect = Console.ReadLine();
                switch (menuSelect.ToLower())
                {
                case "1":
                    newClient.showInfo();
                    Console.WriteLine();
                    break;

                case "2":
                    Console.WriteLine("Would you like an account balance for your Checking or Savings?");
                    string accountSelection = Console.ReadLine();
                    if (accountSelection == "Checking")
                    {
                        newChecking.DisplayAccountBalance();
                        Console.WriteLine();
                    }
                    else if (accountSelection == "Savings")
                    {
                        newSaving.DisplayAccountBalance();
                        Console.WriteLine();
                    }

                    break;

                case "3":
                    Console.WriteLine("Would you like to deposit into your checking or savings account today?");
                    string depositSelection = Console.ReadLine();
                    if (depositSelection == "Checking")
                    {
                        newChecking.DisplayDepositAmount();
                        Console.WriteLine();
                    }
                    else if (depositSelection == "Savings")
                    {
                        newSaving.DisplayDepositAmount();
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Please select Checking or Savings");
                        string response = Console.ReadLine();
                    }
                    break;

                case "4":
                    Console.WriteLine("Would you like to withdraw from your Checking or Savings account today?");
                    string withdrawSelection = Console.ReadLine();
                    if (withdrawSelection == "Checking")
                    {
                        newChecking.DisplayWithdrawAmount();
                        Console.WriteLine();
                    }
                    else if (withdrawSelection == "Savings")
                    {
                        newSaving.DisplayWithdrawAmount();
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Please select Checking or Savings");
                        string response = Console.ReadLine();
                    }
                    break;

                case "5":
                    Console.WriteLine();
                    break;
                }
            } while (menuFunctions != "5");
        }