Пример #1
0
        public bool Transfer(AbstractAccount from, AbstractAccount to, double amount)
        {
            bool status = false;

            try
            {
                Monitor.Enter(from.transactions);

                if (from.sumTransactions() >= amount)
                {
                    from.Withdraw(amount);
                    to.Deposit(amount);
                    status = true;
                }
                else
                {
                    status = false;
                }
                return(status);
            }
            finally
            {
                Monitor.Exit(from.transactions);
            }
        }
Пример #2
0
        private String statementForAccount(AbstractAccount a)
        {
            String s = "";

            //Translate to pretty account type
            //switch(a.GetAccountType()){
            //    case CHECKINGAccount:// Account.CHECKING:
            //        s += "Checking Account\n";
            //        break;
            //    case Account.SAVINGS:
            //        s += "Savings Account\n";
            //        break;
            //    case Account.MAXI_SAVINGS:
            //        s += "Maxi Savings Account\n";
            //        break;
            //}

            s += a.GetAccountTypeHeader();


            //Now total up all the transactions
            double total = 0.0;

            foreach (Transaction t in a.transactions)
            {
                s     += "  " + (t.amount < 0 ? "withdrawal" : "deposit") + " " + ToDollars(t.amount) + "\n";
                total += t.amount;
            }
            s += "Total " + ToDollars(total);
            return(s);
        }
Пример #3
0
 public Customer OpenAccount(AbstractAccount account)
 {
     accounts.Add(account);
     return(this);
 }