Esempio n. 1
0
 /// <summary>
 /// Executes a WithdrawTransaction on an account
 /// </summary>
 /// <param name="transaction">WithdrawTransaction to execute</param>
 public void ExecuteTransaction(WithdrawTransaction transaction)
 {
     try
     {
         transaction.Execute();
     }
     catch (InvalidOperationException exception)
     {
         Console.WriteLine("An error occurred in executing the transaction");
         Console.WriteLine("The error was: " + exception.Message);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Attempts to withdraw funds from an account at a bank
        /// </summary>
        /// <param name="bank">The bank holding account to withdraw from</param>
        static void DoWithdraw(Bank bank)
        {
            Account account = FindAccount(bank);

            if (account != null)
            {
                decimal             amount      = ReadDecimal("Enter the amount");
                WithdrawTransaction transaction = new WithdrawTransaction(account, amount);
                try
                {
                    bank.ExecuteTransaction(transaction);
                }
                catch (InvalidOperationException)
                {
                    transaction.Print();
                    return;
                }
                transaction.Print();
            }
        }