//Methods //Constructor public TransferTransaction(Account fromAccount, Account toAccount, decimal amount) : base(amount) { _fromAccount = fromAccount; _toAccount = toAccount; //Class objects for deposit and withdraw transaction DepositTransaction deposit = new DepositTransaction(_toAccount, _amount); WithdrawTransaction withdraw = new WithdrawTransaction(_fromAccount, _amount); _deposit = deposit; _withdraw = withdraw; }
//Method to perform a deposit operation public static void DoDeposit(Bank bank) { try { Account acc = FindAccount(bank); //If account is found in the FindAccount method, then do the deposit if (acc != null) { decimal depositAmount; Console.Write("Please enter the amount to deposit: "); depositAmount = Convert.ToDecimal(Console.ReadLine()); DepositTransaction transaction = new DepositTransaction(acc, depositAmount); bank.ExecuteTransaction(transaction); } } catch (Exception e) { Console.WriteLine("Error! : " + e.Message); } }