public TransferTransaction(Account fromAccount, Account toAccount, decimal amount) : base(amount)
 {
     this._fromAccount = fromAccount;
     this._toAccount   = toAccount;
     this._amount      = amount;
     this._withdraw    = new WithdrawTransaction(_fromAccount, this._amount);
     this._deposit     = new DepositTransaction(_toAccount, this._amount);
 }
Example #2
0
        static void DoWithdraw(Bank bank)
        {
            Account account = FindAccount(bank);

            if (account != null)
            {
                Console.WriteLine("enter the amount you want to withdraw:");
                int amount = Convert.ToInt32(Console.ReadLine());
                WithdrawTransaction withdrawl = new WithdrawTransaction(account, amount);
                bank.ExecuteTransaction(withdrawl);
            }
        }
Example #3
0
        public TransferTransaction(Account fromAccount, Account toAccount, decimal amount) : base(amount)
        {
            _fromAccount = fromAccount;
            _toAccount   = toAccount;

            DepositTransaction deposit = new DepositTransaction(toAccount, amount);

            _deposit = deposit;
            WithdrawTransaction withdraw = new WithdrawTransaction(fromAccount, amount);

            _withdraw = withdraw;
        }
Example #4
0
        private static void DoWithdraw(Bank bank)
        {
            //Search for an account
            Account account = FindAccount(bank);

            //Take actions if the account is detected
            if (account != null)
            {
                Console.WriteLine("Input amount");
                decimal             amount             = InputToDec(Console.ReadLine());
                WithdrawTransaction currentTransaction = new WithdrawTransaction(account, amount);


                //Ask user to proceed, take action
                if (YNQuestion("Proceed? Y/N"))
                {
                    bank.ExecuteTransaction(currentTransaction);
                }
                else
                {
                    Console.WriteLine("Transaction cancelled");
                }

                //Ask user, then verify user input

                if (YNQuestion("Print transaction details? Y/N"))
                {
                    currentTransaction.Print();
                }
            }
            else
            {
                Console.WriteLine("Withdraw canceled!");
            }

            Console.ReadLine();
        }