Esempio n. 1
0
        public double StartDeposit(string accountSelection)
        {
            var    newSavingsBalance  = new SavingsAccount();
            var    newCheckingBalance = new CheckingAccount();
            double updatedBalance     = 0;

            if (accountSelection == "savings")
            {
                var enterAmount = false;
                while (enterAmount == false)
                {
                    Console.WriteLine("How much would you like to deposit?");
                    var  response = Console.ReadLine();
                    int  amount;
                    bool result = Int32.TryParse(response, out amount);

                    if (result == true)
                    {
                        enterAmount = true;
                        var transactionType = "deposit";
                        newSavingsBalance.SavingsAccountBalance = newSavingsBalance.SavingsAccountBalance + amount;
                        newSavingsBalance.StoreNewTransaction(newSavingsBalance.SavingsAccountBalance);
                        newSavingsBalance.LogToStatement(newSavingsBalance.SavingsAccountBalance, amount, transactionType);
                        updatedBalance = newSavingsBalance.SavingsAccountBalance;
                    }
                    else
                    {
                        Console.WriteLine("Sorry, you didn't enter a valid amount. Please try again.");
                    }
                }
            }

            else
            {
                var enterAmount = false;
                while (enterAmount == false)
                {
                    Console.WriteLine("How much would you like to deposit?");
                    var  response = Console.ReadLine();
                    int  amount;
                    bool result = Int32.TryParse(response, out amount);

                    if (result == true)
                    {
                        enterAmount = true;
                        var transactionType = "deposit";
                        newCheckingBalance.CheckingAccountBalance = newCheckingBalance.CheckingAccountBalance + amount;
                        newCheckingBalance.StoreNewTransaction(newCheckingBalance.CheckingAccountBalance);
                        newCheckingBalance.LogToStatement(newCheckingBalance.CheckingAccountBalance, amount, transactionType);
                        updatedBalance = newCheckingBalance.CheckingAccountBalance;
                    }
                    else
                    {
                        Console.WriteLine("Sorry, you didn't enter a valid amount. Please try again.");
                    }
                }
            }
            return(updatedBalance);
        }
Esempio n. 2
0
        public void StartTransfer(string selection)
        {
            var newSavingsBalance  = new SavingsAccount();
            var newCheckingBalance = new CheckingAccount();

            if (selection == "1")
            {
                var enterAmount = false;
                while (enterAmount == false)
                {
                    Console.WriteLine("How much would you like to transfer from your checking account to your savings account?");
                    var  response = Console.ReadLine();
                    int  amount;
                    bool result = Int32.TryParse(response, out amount);

                    if (result == true)
                    {
                        enterAmount = true;
                        var transactionType = "transfer";
                        newSavingsBalance.SavingsAccountBalance = newSavingsBalance.SavingsAccountBalance + amount;
                        newSavingsBalance.StoreNewTransaction(newSavingsBalance.SavingsAccountBalance);
                        newSavingsBalance.LogToStatement(newSavingsBalance.SavingsAccountBalance, amount, transactionType);

                        newCheckingBalance.CheckingAccountBalance = newCheckingBalance.CheckingAccountBalance - amount;
                        newCheckingBalance.StoreNewTransaction(newCheckingBalance.CheckingAccountBalance);
                        newCheckingBalance.LogToStatement(newCheckingBalance.CheckingAccountBalance, amount, transactionType);
                    }
                    else
                    {
                        Console.WriteLine("Sorry, you didn't enter a valid amount. Please try again.");
                    }
                }
            }

            else
            {
                var enterAmount = false;
                while (enterAmount == false)
                {
                    Console.WriteLine("How much would you like to transfer from your savings account to your checking account?");
                    var  response = Console.ReadLine();
                    int  amount;
                    bool result = Int32.TryParse(response, out amount);

                    if (result == true)
                    {
                        enterAmount = true;
                        var transactionType = "transfer";
                        newCheckingBalance.CheckingAccountBalance = newCheckingBalance.CheckingAccountBalance + amount;
                        newCheckingBalance.StoreNewTransaction(newCheckingBalance.CheckingAccountBalance);
                        newCheckingBalance.LogToStatement(newCheckingBalance.CheckingAccountBalance, amount, transactionType);

                        newSavingsBalance.SavingsAccountBalance = newSavingsBalance.SavingsAccountBalance - amount;
                        newSavingsBalance.StoreNewTransaction(newSavingsBalance.SavingsAccountBalance);
                        newSavingsBalance.LogToStatement(newSavingsBalance.SavingsAccountBalance, amount, transactionType);
                    }
                    else
                    {
                        Console.WriteLine("Sorry, you didn't enter a valid amount. Please try again.");
                    }
                }
            }
        }