static void Main(string[] args)
        {
            //OBJECT INSTANTIATING
            Account client = new Account();         //establishing our one client

            Checking checking = new Checking(2000); //checking account

            checking.AccountNumb();
            Reserve reserve = new Reserve(500);//reserve account

            reserve.AccountNumb();
            Savings savings = new Savings(18000);//savings account

            savings.AccountNumb();

            //CLIENT AND ACCOUNT NAME STRING PARAMETERS FOR STREAMWRITER
            string streamcheckingaccount = ("Account Number: " + checking.AcctNumber);
            string streamreserveaccount  = ("Account Number: " + reserve.AcctNumber);
            string streamsavingsaccount  = ("Account Number: " + savings.AcctNumber);
            string streamclientinfo      = (client.ClientInfo());
            string checkingaccounttype   = (checking.AccountType);
            string reserveaccounttype    = (reserve.AccountType);
            string savingsaccounttype    = (savings.AccountType);

            using (StreamWriter checkingsummary = new StreamWriter("CheckingSummary.txt", true))
            {
                checkingsummary.WriteLine(checkingaccounttype);
                checkingsummary.WriteLine(streamclientinfo);
                checkingsummary.WriteLine(streamcheckingaccount);
            }
            using (StreamWriter reservesummary = new StreamWriter("ReserveSummary.txt", true))
            {
                reservesummary.WriteLine(reserveaccounttype);
                reservesummary.WriteLine(streamclientinfo);
                reservesummary.WriteLine(streamreserveaccount);
            }
            using (StreamWriter savingsummary = new StreamWriter("SavingsSummary.txt", true))
            {
                savingsummary.WriteLine(savingsaccounttype);
                savingsummary.WriteLine(streamclientinfo);
                savingsummary.WriteLine(streamcheckingaccount);
            }

            bool test = false;//way to break out of menu do-while loop

            do
            {
                //PARAMETERS FOR STREAMWRITER THAT ARE TO BE DONE INSIDE OF THE LOOP
                string checkingDepositPara    = ($"Transaction: +${checking.Deposit} at {DateTime.Now.ToString()} Current Balance: ${checking.Bal}");
                string checkingWithdrawalPara = ($"Transaction: -${checking.Withdrawal} at {DateTime.Now.ToString()} Current Balance: ${checking.Bal}");
                string reserveDepositPara     = ($"Transaction: +${reserve.Deposit} at {DateTime.Now.ToString()} Current Balance: ${reserve.Bal}");
                string reserveWithdrawalPara  = ($"Transaction: -${reserve.Withdrawal} at {DateTime.Now.ToString()} Current Balance: ${reserve.Bal}");
                string savingsDepositPara     = ($"Transaction: +${savings.Deposit} at {DateTime.Now.ToString()} Current Balance: ${savings.Bal}");
                string savingsWithdrawalPara  = ($"Transaction: -${savings.Withdrawal} at {DateTime.Now.ToString()} Current Balance: ${savings.Bal}");

                //INSTANTIATING STREAMWRITER FILES
                //checking
                using (StreamWriter checkingAccountStreamSummary = new StreamWriter("CheckingSummary.txt", true))
                {
                    if (checking.Deposit > 0)
                    {
                        checkingAccountStreamSummary.WriteLine(checkingDepositPara);
                        checking.Deposit = 0;
                    }
                    if (checking.Withdrawal > 0)
                    {
                        checkingAccountStreamSummary.WriteLine(checkingWithdrawalPara);
                        checking.Withdrawal = 0;
                    }
                }
                //reserve
                using (StreamWriter reserveAccountStreamSummary = new StreamWriter("ReserveSummary.txt", true))
                {
                    if (reserve.Deposit > 0)
                    {
                        reserveAccountStreamSummary.WriteLine(reserveDepositPara);
                        reserve.Deposit = 0;
                    }
                    if (reserve.Withdrawal > 0)
                    {
                        reserveAccountStreamSummary.WriteLine(reserveWithdrawalPara);
                        reserve.Withdrawal = 0;
                    }
                }
                //savings
                using (StreamWriter savingsAccountStreamSummary = new StreamWriter("SavingsSummary.txt", true))
                {
                    if (savings.Deposit > 0)
                    {
                        savingsAccountStreamSummary.WriteLine(savingsDepositPara);
                        savings.Deposit = 0;
                    }
                    if (savings.Withdrawal > 0)
                    {
                        savingsAccountStreamSummary.WriteLine(savingsWithdrawalPara);
                        savings.Withdrawal = 0;
                    }
                }
                //MENU ONLINE BANKING-- this menu is a do-while loop with a nested switch statement.
                //Choices are Client Info, Account Info for each account type, Deposit (for each), Withdrawal (for each), or Exit.

                Console.WriteLine("Hit Enter to Display Banking Menu");
                Console.ReadLine();

                client.DisplayMenu();                   //the online banking menu
                string userchoice = Console.ReadLine(); //user input from menu options

                switch (userchoice.ToUpper())
                {
                case "1":    //Display Client Info
                    Console.Clear();
                    Console.WriteLine(client.ClientInfo());
                    break;

                case "2A":    //Display Checking Account Balance
                    Console.Clear();
                    checking.Balance();
                    Console.WriteLine("Checking Account Balance: $" + checking.Bal);
                    break;

                case "2B":    //Display Checking Account Balance
                    Console.Clear();
                    reserve.Balance();
                    Console.WriteLine("Reserve Account Balance: $" + reserve.Bal);
                    break;

                case "2C":    //Display Savings Account Balance
                    Console.Clear();
                    savings.Balance();
                    Console.WriteLine("Savings Account Balance: $" + savings.Bal);
                    break;

                case "3A":    //Checking Account Deposit
                    Console.Clear();
                    Console.WriteLine("How much would you like to deposit?");
                    checking.Deposit = double.Parse(Console.ReadLine());
                    Console.WriteLine("You deposited: $" + checking.Deposit);
                    checking.DepositBalance(checking.Deposit);
                    break;

                case "3B":
                    Console.Clear();    //Reserve Account Deposit
                    Console.WriteLine("How much would you like to deposit?");
                    reserve.Deposit = double.Parse(Console.ReadLine());
                    Console.WriteLine("You deposited: $" + reserve.Deposit);
                    reserve.DepositBalance(reserve.Deposit);
                    break;

                case "3C":
                    Console.Clear();    //Savings Account Deposit
                    Console.WriteLine("How much would you like to deposit?");
                    savings.Deposit = double.Parse(Console.ReadLine());
                    Console.WriteLine("You deposited: $" + savings.Deposit);
                    savings.DepositBalance(savings.Deposit);
                    break;

                case "4A":    //Checking Account Withdrawal
                    Console.Clear();
                    Console.WriteLine("How much would you like to withdraw?");
                    checking.Withdrawal = double.Parse(Console.ReadLine());
                    Console.WriteLine("You withdrew: $" + checking.Withdrawal);
                    checking.WithBalance(checking.Withdrawal);
                    break;

                case "4B":
                    Console.Clear();    //Reserve Account Withdrawal
                    Console.WriteLine("How much would you like to withdraw?");
                    reserve.Withdrawal = double.Parse(Console.ReadLine());
                    Console.WriteLine("You withdrew: $" + reserve.Withdrawal);
                    reserve.WithBalance(reserve.Withdrawal);
                    break;

                case "4C":
                    Console.Clear();     //Savings Account Withdrawal
                    Console.WriteLine("How much would you like to withdraw?");
                    savings.Withdrawal = double.Parse(Console.ReadLine());
                    Console.WriteLine("You withdrew: $" + savings.Withdrawal);
                    savings.WithBalance(savings.Withdrawal);
                    break;

                case "5":
                    Console.Clear();    //Exit Banking
                    Console.WriteLine("You have chosen to exit the online banking. Thanks and come again!");
                    Environment.Exit(0);
                    break;

                default:    //catch all, breaks the loop
                    Console.Clear();
                    test = false;
                    break;
                }
            } while (!test);
        }
Esempio 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
        }