Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            int userInput; //declare variable to store user menu selection

            decimal userWithdrawalAmount;
            decimal userDepositAmount;

            Console.WriteLine("Hello, welcome to WCCI Bank. Please enter your first name.");
            string firstName = (Console.ReadLine());

            Console.WriteLine("Please enter your last name");
            string lastName = (Console.ReadLine());
            string userName = (firstName + " " + lastName);

            Console.Clear();
            Console.WriteLine("Welcome back " + userName);


            Checking accountc = new Checking(120875, 5000, userName);
            Savings  accounts = new Savings(120875, 10000, userName);
            Reserve  accountr = new Reserve(120875, 1500, userName);

            do
            {
                Console.WriteLine("Here is your current account information:\n");
                Console.WriteLine("User ID: {0}", accountc.UserID);
                Console.WriteLine("Checking Account Balance: {0:C}", accountc.AccountBalance);
                Console.WriteLine("Reserve Account Balance: {0:C}", accountr.AccountBalance);
                Console.WriteLine("Savings Account Balance: {0:C}\n\n\n", accounts.AccountBalance);

                Console.WriteLine("How can we help you today?");
                Console.WriteLine("Please enter a number from the menu below. \n");
                Console.WriteLine("CHECKING ACCOUNT \n 1: Deposit Funds " + "2: Withdraw Funds " + "3: Show Balance");
                Console.WriteLine("RESERVE ACCOUNT  \n 4: Deposit Funds " + "5: Withdraw Funds " + "6: Show Balance");
                Console.WriteLine("SAVINGS ACCOUNT  \n 7: Deposit Funds " + "8: Withdraw Funds " + "9: Show Balance");
                Console.WriteLine("VIEW CLIENT INFORMATION: 10 \n \nEXIT: \n 11");

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

                if (userInput == 1) //conditional statement that addresses checking deposit.
                {
                    Console.WriteLine("How much do you want deposit to your checking account?");
                    userDepositAmount = decimal.Parse(Console.ReadLine());
                    accountc.Deposit(userDepositAmount); //call method that corresponds with checking deposit
                    Console.WriteLine("Thank you for your deposit!");
                    Console.WriteLine("Please press any key to return to main menu");
                    Console.ReadLine();
                }
                else if (userInput == 2)
                {
                    // conditional statement that addresses checking withdrawal
                    Console.WriteLine("How much do you want to withdraw from your checking account?");
                    userWithdrawalAmount = decimal.Parse(Console.ReadLine());

                    accountc.Withdrawal(userWithdrawalAmount); //call method that corresponds with checking withdrawal
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }

                else if (userInput == 3) //shows checking account balance
                {
                    accountc.ShowBalanceChecking();
                    System.Threading.Thread.Sleep(1000);
                }


                else if (userInput == 4)
                {
                    //conditional statement that addresses reserve account deposit

                    Console.WriteLine("How much do you want deposit to your reserve account?");
                    userDepositAmount = decimal.Parse(Console.ReadLine());
                    accountr.Deposit(userDepositAmount); //call method that corresponds to reserve deposit
                    Console.WriteLine("Thank you for your deposit!");
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }
                else if (userInput == 5)
                {
                    //conditional statement that addresses reserve account withdrawal
                    Console.WriteLine("How much do you want to withdraw from your reserve account?");
                    userWithdrawalAmount = decimal.Parse(Console.ReadLine());

                    accountr.Withdrawal(userWithdrawalAmount); //call method that corresponds to reserve withdrawal
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }

                else if (userInput == 6) //shows reserve account balance
                {
                    accountr.ShowBalanceReserve();
                    Console.ReadLine();
                }



                else if (userInput == 7)
                {
                    //conditional statement that addresses savings account deposit
                    Console.WriteLine("How much do you want deposit to your savings account?");
                    userDepositAmount = decimal.Parse(Console.ReadLine());
                    accounts.Deposit(userDepositAmount); //call method that corresponds to savings deposit
                    Console.WriteLine("Thank you for your deposit!");
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }
                else if (userInput == 8)
                {
                    //conditional statement that addresses savings account withdrawal
                    Console.WriteLine("How much do you want to withdraw?");
                    userWithdrawalAmount = decimal.Parse(Console.ReadLine());

                    accounts.Withdrawal(userWithdrawalAmount); //call method that corresponds to savings withdrawal
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }

                else if (userInput == 9)
                {
                    accounts.ShowBalanceSavings();
                    Console.ReadLine();
                }

                else if (userInput == 10)
                {
                    //conditional statement that displays client information
                    Console.Clear();
                    Console.WriteLine("\n\n\nCLIENT NAME: " + userName + "\nUSER ID:" + accountc.UserID + "\nADDRESS: 120875 Happy Lane, Cleveland, OH 44120 \nACCOUNTHOLDER SINCE: 2010");
                    System.Threading.Thread.Sleep(4000);
                    Console.WriteLine("Please press enter to return to main menu");
                    Console.ReadLine();
                }
                else if (userInput == 11)
                {
                    //conditional statement that calls method to quit the program
                    accountc.Quit();
                }
                else
                { //conditional statement that addresses answers that don't fall between numbers 1-11
                    Console.WriteLine("Sorry, I don't understand this selection. ");
                    Console.WriteLine("Please press enter to return to the main menu");
                    Console.ReadLine();
                }
            } while (userInput != 11);
        }