コード例 #1
0
        static void Main(string[] args)
        {
            //instantiate below
            Client          client2   = new Client(clientName, clientPhoneNumber, clientAddress, clientRepresentative);
            CheckingAccount checking1 = new CheckingAccount();
            SavingsAccount  savings1  = new SavingsAccount();

            do
            {
                Console.WriteLine("Select the number of your choice: ");
                Console.WriteLine("1: View Client Information");
                Console.WriteLine("2: View Account Balances");
                Console.WriteLine("3: Deposit Funds");
                Console.WriteLine("4: Withdraw Funds");
                Console.WriteLine("5: Quit");
                var userChoice = Console.ReadLine();
                Console.WriteLine();
                if (!Int32.TryParse(userChoice, out num))
                {
                    continue;
                }

                if (userChoice == "5")
                {
                    Environment.Exit(0);
                }

                Console.WriteLine("Choice = " + userChoice);

                if (userChoice == "1")
                {
                    client2.ClientWork();
                    Console.WriteLine();
                }
                else if (userChoice == "2")

                {
                    Console.WriteLine("1 - Checking Balance");
                    Console.WriteLine("2 - Savings Balance");
                    int accountSelection = int.Parse(Console.ReadLine());
                    if (accountSelection == 1)
                    {
                        checking1.CheckBalance();
                        Console.WriteLine();
                    }
                    else if (accountSelection == 2)
                    {
                        savings1.CheckBalance();
                        Console.WriteLine();
                    }
                }
                else if (userChoice == "3")
                {
                    Console.WriteLine("1 - Checking Deposit");
                    Console.WriteLine("2 - Savings Deposit");
                    int withdrawalSelection = int.Parse(Console.ReadLine());
                    if (withdrawalSelection == 1)
                    {
                        checking1.AccountDeposit();
                        Console.WriteLine();
                    }
                    else if (withdrawalSelection == 2)
                    {
                        savings1.AccountDeposit();
                        Console.WriteLine();
                    }
                }
                else if (userChoice == "4")
                {
                    Console.WriteLine("1 - Checking Withdrawal");
                    Console.WriteLine("2 - Savings Withdrawal");
                    int withdrawalSelection = int.Parse(Console.ReadLine());
                    if (withdrawalSelection == 1)
                    {
                        checking1.AccountWithdrawal();
                        Console.WriteLine();
                    }
                    else if (withdrawalSelection == 2)
                    {
                        savings1.AccountWithdrawal();
                        Console.WriteLine();
                    }
                }
            } while (true);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Bank of Gatlantiss.");
            Console.WriteLine("It is nice to see you again.");

            Client          mikeClient = new Client();
            CheckingAccount mikeCh     = new CheckingAccount();
            SavingsAccount  mikeSv     = new SavingsAccount();

            //need one general object, one checking object, one savings object

            bool isBanking = true;

            while (isBanking == true)
            {
                Console.WriteLine("Please choose from the following options (choose a number):");
                Console.WriteLine("\t1.\tView your account information.");
                Console.WriteLine("\t2.\tView your total account balance.");
                Console.WriteLine("\t3.\tWithdraw funds");
                Console.WriteLine("\t4.\tDeposit funds");
                Console.WriteLine("\t5.\tEnd Banking");
                int choice = int.Parse(Console.ReadLine()); //this line reads user input

                if (choice == 1)                            //user checks client info
                {
                    mikeClient.ClientInfo();
                }

                if (choice == 2)  //user checks balances
                {
                    Console.WriteLine();
                    Console.WriteLine("Which account would you like to check?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountInfo();
                        mikeCh.InterestEarned();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountInfo();
                        mikeSv.InterestEarned();
                    }
                }

                if (choice == 3)  //withdrawals
                {
                    Console.WriteLine();
                    Console.WriteLine("From which account would you like to withdraw funds?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountWithdrawal();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountWithdrawal();
                    }
                }

                if (choice == 4)  //deposits
                {
                    Console.WriteLine();
                    Console.WriteLine("To which account would you like to deposit funds?");
                    Console.WriteLine("\t1.\tchecking");
                    Console.WriteLine("\t2.\tsavings");
                    int choiceB = int.Parse(Console.ReadLine());

                    if (choiceB == 1)
                    {
                        mikeCh.AccountDeposit();
                    }

                    if (choiceB == 2)
                    {
                        mikeSv.AccountDeposit();
                    }
                }

                if (choice == 5)  //quit program
                {
                    Console.WriteLine("Thank you for banking with us today!");
                    Console.WriteLine("I hope we've EARNED your trust!");
                    Console.WriteLine("Press ENTER to leave the bank.");
                    Console.ReadLine();
                    isBanking = false;  //ends loop
                }
            }

            Environment.Exit(0);  //exits program after loop ends
        }