static void Main(string[] args)
        {
            string userExit = "";

            do
            {
                // You are Balthazar Runze and you have 567.45 in your checking and 1243.22 in your savings. Happy banking!
                //Program will loop and hold values of balances for multiple transactions before exiting
                //Classes organized as Accounts(abstract) : Clients : Checking/Savings
                Console.Clear();
                Console.WriteLine("Welcome to Crystal Ball Banking, please choose from the following menu choices.\n\n");
                Console.WriteLine("1 - View Client Information\n");
                Console.WriteLine("2 - View Account Balance\n");
                Console.WriteLine("3 - Deposit Funds\n");
                Console.WriteLine("4 - Withdraw Funds\n");
                Console.WriteLine("5 - Exit\n");

                int menuChoice = int.Parse(Console.ReadLine());

                //Menu beginning - 5 total choices with 2 choice sub menu for choices 1-4
                if (menuChoice == 1)
                {
                    Client oneClient = new Client();
                    oneClient.ClientInfo();

                    //This is a main method that we'll use to return to beginning of menu
                    userExit = backOrExit();
                }

                else if (menuChoice == 2)
                {
                    //submenu choices - will be the same for menuChoice 2-4
                    Console.WriteLine("\na - Checking Account\n");
                    Console.WriteLine("b - Savings Account\n");
                    string accountChoice = Console.ReadLine().ToLower();

                    if (accountChoice == "a")
                    {
                        Checking displayBalance = new Checking();
                        Console.WriteLine(displayBalance.TotalBalance());
                    }
                    else if (accountChoice == "b")
                    {
                        Savings displayBalance = new Savings();
                        Console.WriteLine(displayBalance.TotalBalance());
                    }

                    userExit = backOrExit();
                }

                else if (menuChoice == 3)
                {
                    Console.WriteLine("\na - Checking Account\n");
                    Console.WriteLine("b - Savings Account\n");
                    string accountChoice = Console.ReadLine().ToLower();

                    Console.WriteLine("\nEnter the amount to Deposit\n");
                    double userDeposit = double.Parse(Console.ReadLine());

                    if (accountChoice == "a")
                    {
                        Checking newDeposit = new Checking(userDeposit, 0);

                        Console.WriteLine("\nYour current balance is " + newDeposit.Deposit());
                    }
                    else if (accountChoice == "b")
                    {
                        Savings newDeposit = new Savings(userDeposit, 0);
                        Console.WriteLine("\nYour current balance is " + newDeposit.Deposit());
                    }

                    userExit = backOrExit();
                }

                else if (menuChoice == 4)
                {
                    Console.WriteLine("\na - Checking Account\n");
                    Console.WriteLine("b - Savings Account\n");
                    string accountChoice = Console.ReadLine().ToLower();

                    Console.WriteLine("\nEnter the amount to Withdraw\n");
                    double userWithdraw = double.Parse(Console.ReadLine());

                    if (accountChoice == "a")
                    {
                        Checking newWithdraw = new Checking(0, userWithdraw);
                        Console.WriteLine("\nYour current balance is " + newWithdraw.Withdraw());
                    }
                    else if (accountChoice == "b")
                    {
                        Savings newWithdraw = new Savings(0, userWithdraw);

                        Console.WriteLine("\nYour current balance is " + newWithdraw.WithdrawWithMinimum());
                    }

                    userExit = backOrExit();
                }

                else if (menuChoice == 5)
                {
                    Console.WriteLine("\nAre you sure you would like to EXIT this session? YES/NO ");

                    userExit = Console.ReadLine().ToUpper();
                }
            }while (userExit == "NO");
            Console.Clear();

            Console.WriteLine("Thank you for choosing Crystal Ball Banking. Have a nice day! \n\n");
        }
示例#2
0
        static void Main(string[] args)
        {
            Client   client1  = new Bank_Account_Project.Client("Razvan", "Crisan", 1234);
            Savings  savings  = new Savings(1000.00);
            Checking checking = new Checking(350.00);



            //start of the do while loop
            string newTransaction = "";

            do
            {
                //When user launches Applicating they will see this menu.
                //and will cycle after every transaction with a do-while loop
                double minBalance = 200.00;
                Console.WriteLine("Please enter the number of your desired option.");
                Console.WriteLine("1. View Client Information");
                Console.WriteLine("2. View Account Balance");
                Console.WriteLine("3. Deposit Funds");
                Console.WriteLine("4. Withdraw Funds");
                Console.WriteLine("5. Exit");
                Console.WriteLine();

                //readline for user to cycle through options.
                int menuOptions = int.Parse(Console.ReadLine());

                //if else statement for first option
                if (menuOptions == 1)
                {
                    client1.displayInfo();
                }
                //if else statement for a/b options.
                if (menuOptions == 2)
                {
                    Console.WriteLine("a. Checkings Account");
                    Console.WriteLine("b. Savings Account");

                    char menuOptions2 = char.Parse(Console.ReadLine().ToLower());
                    if (menuOptions2 == 'a')
                    {
                        checking.Balance();
                    }
                    else if (menuOptions2 == 'b')
                    {
                        savings.Balance();
                    }
                }

                //if else statement for option 3 (deposit).
                if (menuOptions == 3)
                {
                    Console.WriteLine("Which account would you like to deposit into?");
                    Console.WriteLine("a. Checkings");
                    Console.WriteLine("b. Savings");
                    //
                    char menuOptions2 = char.Parse(Console.ReadLine().ToLower());
                    if (menuOptions2 == 'a')
                    {
                        //checking deposit
                        Console.WriteLine("Enter deposit amount:");
                        double depositAmount = double.Parse(Console.ReadLine());
                        checking.Deposit();
                        Console.WriteLine("Your new balance is: $" + (checking.Deposit() + depositAmount));
                    }
                    else if (menuOptions2 == 'b')
                    {
                        //savings deposit
                        Console.WriteLine("Enter deposit amount:");
                        savings.depositAmount = double.Parse(Console.ReadLine());
                        double newBalance = savings.Deposit();
                        Console.WriteLine("Your new balance is: $" + (savings.Deposit()));
                    }
                }

                //if else statement for withdraw option 4
                if (menuOptions == 4)
                {
                    Console.WriteLine("Which account would you like to withdraw from?");
                    Console.WriteLine("a. Checkings");
                    Console.WriteLine("b. Savings");
                    char menuOptions2 = char.Parse(Console.ReadLine().ToLower());
                    if (menuOptions2 == 'a')
                    {
                        //checkings withdraw pulling methods from Checking class
                        Console.WriteLine("Enter withdraw amount:");
                        checking.withdrawAmount = double.Parse(Console.ReadLine());
                        double newBalance = checking.Withdraw();
                        Console.WriteLine("Your new Balance is: $" + checking.Withdraw());

                        if (newBalance < 0)
                        {
                            //if user pull more money than he has in his account
                            //then user will be prompted to enter new amount
                            //this amount will pull money from his original checking balance.
                            Console.WriteLine("You cannot overdraft from checking.");
                            Console.WriteLine("Enter new withdraw amount");
                            checking.withdrawAmount = double.Parse(Console.ReadLine());
                            checking.Withdraw();
                            Console.WriteLine("Balance after withdraw is: $" + (checking.Withdraw()));
                        }
                    }
                    else if (menuOptions2 == 'b')
                    {
                        //savings withdraw
                        Console.WriteLine("Enter withdraw amount:");
                        savings.withdrawAmount = double.Parse(Console.ReadLine());
                        savings.Withdraw();
                        double newBalance2 = savings.Withdraw();
                        Console.WriteLine("Balance after withdraw is: $" + (savings.Withdraw()));
                        if (minBalance <= 200.00)
                        {
                            //this amount will not let the user go under their $200 limit
                            //then user will be prompted to enter new amount
                            //this amount will pull money from his original savings balance.
                            Console.WriteLine("You are attempting to withdraw more");
                            Console.WriteLine("than your minimum balance allows. Please enter new amount");
                            savings.withdrawAmount = double.Parse(Console.ReadLine());
                            Console.WriteLine("Balance after withdraw is: $" + (savings.Withdraw()));
                        }
                    }
                }

                //if else statement for exit option
                else if (menuOptions == 5)
                {
                    Console.WriteLine("Have a great day!");
                }
                //the user will be asked to make another transaction.
                else
                {
                    Console.WriteLine("Would you like to make another transaction? YES/NO");
                    newTransaction = Console.ReadLine().ToUpper();
                }
            }
            //do-while loop will end program if user selects no
            while (newTransaction == "YES");
            if (newTransaction == "NO")
            {
                Console.WriteLine("Thank you for visiting our bank, have a nice day!");
            }


            //The End
        }