Beispiel #1
0
 public void transfer(double amount, Account from, Account to)
 {   
     if(!accounts.Contains(from))
         throw new ArgumentException("Source account does not belong to the customer");
     if (!accounts.Contains(to))
         throw new ArgumentException("Target account does not belong to the customer");
     to.deposit(from.withdraw(amount));
 }
        public Customer transfer(Account fromAccount, Account toAccount, double transferAmoumt)
        {
            //in statement transfer will appear as withdraw for one account and deposit for another
            //TO DO It should be different
            fromAccount.withdraw(transferAmoumt, true);
            toAccount.deposit(transferAmoumt, true);

            return this;
        }
Beispiel #3
0
        public void TransferFunds(Account sourceAccount, Account targetAccount, double amount)
        {
            if (sourceAccount.Balance() > amount)
            {
                sourceAccount.withdraw(amount);
                targetAccount.deposit(amount);
            }
            else
            {
                String msg = GetInsufficientFundsMessage(sourceAccount.Balance(), amount);

                throw new Exception(msg);
            }
        }