Exemple #1
0
        //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;
        }
Exemple #2
0
        //Method to perform a withdraw operation
        public static void DoWithdraw(Bank bank)
        {
            try
            {
                Account acc = FindAccount(bank);

                //If account is found in the FindAccount method, then do the withdraw
                if (acc != null)
                {
                    decimal withdrawAmount;

                    Console.Write("Please enter the amount to withdraw: ");
                    withdrawAmount = Convert.ToDecimal(Console.ReadLine());

                    WithdrawTransaction transaction = new WithdrawTransaction(acc, withdrawAmount);

                    bank.ExecuteTransaction(transaction);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error! : " + e.Message);
            }
        }