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

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