public bool AreNullOrNotRelated(Parent parent, Child child) { if (parent == null || child == null) return true; if (!parent.HasChild(child)) { throw new TardisBankException("'{0}' is not a child of '{1}'", child.UserName, parent.UserName); } return false; }
void WithdrawInternal(Parent parent, decimal amount, string description, string insufficientFundsMessage) { if (parent == null) { throw new ArgumentNullException("parent"); } if (description == null) { throw new ArgumentNullException("description"); } if (!parent.HasChild(this)) { throw new CashWithdrawException("Not Your Parent"); } if (amount > Account.Balance) { throw new CashWithdrawException(insufficientFundsMessage); } Account.AddTransaction(description, -amount); }
void WithdrawInternal(Parent parent, decimal amount, string description, string insufficientFundsMessage) { if (parent == null) { throw new ArgumentNullException("parent"); } if (description == null) { throw new ArgumentNullException("description"); } if (!parent.HasChild(this)) { throw new CashWithdrawException("Not Your Parent"); } if (amount > this.Account.Balance) { throw new CashWithdrawException(insufficientFundsMessage); } this.Account.AddTransaction(description, -amount); }