//Constructors
        public Client(string clientName, double savingsOpen, double checkingOpen, double reserveOpen)    //Using type of account as key for expedience
        {
            ClientName           = clientName;
            ClientAccountNumbers = clientAccountNumbers;
            ClientAccountNumbers.Add("Checking", 1234);
            ClientAccountNumbers.Add("Savings ", 7890);
            ClientAccountNumbers.Add("Reserve ", 2468);

            Checking currentChecking = new Checking(ClientAccountNumbers["Checking"], ClientName, checkingOpen);

            ClientAccounts.Add(1234, currentChecking);

            Savings currentSavings = new Savings(ClientAccountNumbers["Savings "], ClientName, savingsOpen);

            ClientAccounts.Add(7890, currentSavings);

            Reserve currentReserve = new Reserve(ClientAccountNumbers["Reserve "], ClientName, reserveOpen);

            ClientAccounts.Add(2468, currentReserve);
        }
        static void Main(string[] args)
        {
            //Objex
            Checking myChecking = new Checking();
            Savings  mySavings  = new Savings();
            Reserve  myReserve  = new Reserve();
            Accounts myAccount  = new Accounts();

            Console.WriteLine("Welcome to The First National Bank of Keith!");
            Console.WriteLine();
            //bool used in do-while loop
            bool cycleAccount = true;

            //do-while loop cycles through program
            do
            {
                Console.WriteLine("Which account would you like to access today?\nChecking, Savings, or Reserve?");
                string accountType = Console.ReadLine();
                accountType = accountType.ToLower();
                if (accountType == "checking") //Checking account functions
                {
                    myChecking.DisplayAccountStats();
                    Console.WriteLine("What action would you like to take?\nWithdraw funds\nDeposit funds");
                    Console.WriteLine();
                    string checkingAction = Console.ReadLine();
                    checkingAction = checkingAction.ToLower();
                    if (checkingAction == "withdraw")
                    {
                        myChecking.withdrawMethod(0);
                        myChecking.DisplayAccountStats();
                    }
                    else if (checkingAction == "deposit")
                    {
                        myChecking.depositMethod(0);
                        myChecking.DisplayAccountStats();
                    }
                    else
                    {
                        Console.WriteLine("Error: Invalid response.");
                        Console.WriteLine();
                    }
                }

                else if (accountType == "savings")  //Savings Account functions
                {
                    mySavings.DisplayAccountStats();
                    Console.WriteLine("What action would you like to take?\nWithdraw funds\nDeposit funds");
                    Console.WriteLine();
                    string savingsAction = Console.ReadLine();
                    savingsAction = savingsAction.ToLower();
                    if (savingsAction == "withdraw")
                    {
                        mySavings.withdrawMethod(0);
                        mySavings.DisplayAccountStats();
                    }
                    else if (savingsAction == "deposit")
                    {
                        mySavings.depositMethod(0);
                        mySavings.DisplayAccountStats();
                    }
                    else
                    {
                        Console.WriteLine("Error: Invalid response.");
                        Console.WriteLine();
                    }
                }
                else if (accountType == "reserve")  //Reserve Account functions
                {
                    myReserve.DisplayAccountStats();
                    Console.WriteLine("What action would you like to take?\nWithdraw funds\nDeposit funds");
                    Console.WriteLine();
                    string reserveAction = Console.ReadLine();
                    reserveAction = reserveAction.ToLower();
                    if (reserveAction == "withdraw")
                    {
                        myReserve.withdrawMethod(0);
                        myReserve.DisplayAccountStats();
                    }
                    else if (reserveAction == "deposit")
                    {
                        myReserve.depositMethod(0);
                        myReserve.DisplayAccountStats();
                    }
                    else
                    {
                        Console.WriteLine("Error: Invalid response.");
                        Console.WriteLine();
                    }
                }
                else
                {
                    Console.WriteLine("Error: Invalid response.");
                    Console.WriteLine();
                }
            } while (cycleAccount == true);


            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Checking checking = new Checking();
            Savings  savings  = new Savings();
            Reserve  reserve  = new Reserve();
            Accounts account1 = new Accounts();

            string clientInput;

            StringBuilder mainMenu = new StringBuilder();

            mainMenu.Append("OurBank Main Menu\n");
            mainMenu.Append("View Client Information, Press '1'\n");
            mainMenu.Append("View Account Balance Information, Press '2'\n");
            mainMenu.Append("To Deposit Funds from checking, Press '3'\n");
            mainMenu.Append("To Withdraw Funds from checking, Press '4'\n");
            mainMenu.Append("To Exit the Application, Press '5'\n");
            mainMenu.Append("Thank you for being a valued OurBank customer!\n");
            mainMenu.Append("Today's Date and time is: " + DateTime.Now + "\n");
            Console.WriteLine(mainMenu.ToString());
            clientInput = Console.ReadLine().ToUpper();
            if (clientInput == "1")
            {
                account1.PrintStats();
            }
            else if (clientInput == "2")
            {
                checking.PrintCheckingStats();
                reserve.PrintReserveStats();
                savings.PrintStats1();
            }
            else if (clientInput == "3")
            {
                checking.Deposit();
            }
            else if (clientInput == "4")
            {
                Console.WriteLine("Do you want to write a check (1), or withdraw from savings (2)?");
                int userResponse = Convert.ToInt32(Console.ReadLine());
                if (userResponse == 1)
                {
                    checking.WriteCheck();
                }
                else
                {
                    savings.Withdraw();
                }
            }
            Console.ReadKey();


            StreamWriter checkingWriter = new StreamWriter("checking.txt");

            using (checkingWriter)
            {
                checkingWriter.Write(DateTime.Now);
            }
            StreamWriter savingsWriter = new StreamWriter("savings.txt");

            using (savingsWriter)
            {
                savingsWriter.Write(DateTime.Now);
            }
            StreamWriter reserveWriter = new StreamWriter("reserve.txt");

            using (reserveWriter)
            {
                reserveWriter.Write(DateTime.Now);
            }
        }