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); } }
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); }
public Customer OpenAccount(AbstractAccount account) { accounts.Add(account); return(this); }