Exemplo n.º 1
0
        public TransactionResult Withdraw(WithdrawTransaction withdrawTransaction)
        {
            // Check for ISF
            if (withdrawTransaction.GetAmount() > _balance)
            {
                return TransactionResult.InsufficientFunds;
            }
            else
            {
                _balance -= withdrawTransaction.GetAmount();
                _transactionHistory.Add(withdrawTransaction);
            }

            return TransactionResult.Success;
        }
Exemplo n.º 2
0
        public void CustomerWithdraw(Customer name)
        {
            // Get the source account
            Console.Write("\n Select account (1 - from Checkings Account, 2 - from Savings Account): ");
            var selection = Convert.ToInt32(Console.ReadLine());
            var sourceAccount = selection == 1 ? (Account)name.GetCheckingsAccount() : (Account)name.GetSavingsAccount();

            // Get the withdraw amount
            Console.Write("\n Enter Amount: ");
            var withdrawAmount = Convert.ToDouble((Console.ReadLine()));

            // Create a new transaction with the withdraw info
            var withdrawTransaction = new WithdrawTransaction(sourceAccount, withdrawAmount).FinalizeTransaction();

            if (withdrawTransaction == TransactionResult.Success)
            {
                Console.WriteLine("\n\tWithdrawl Completed");
            }
            else
            {
                Console.WriteLine("\n\tInsufficient funds, account balance $" + sourceAccount.GetAccountBalance());
            }
        }