Skip to content

Instantly share code, notes, and snippets.

@tatey
Created October 31, 2008 11:44
Show Gist options
  • Save tatey/21288 to your computer and use it in GitHub Desktop.
Save tatey/21288 to your computer and use it in GitHub Desktop.
/**
* Charges annual fee on all accounts if an annual fee is applicable. Returns
* total amount of revenue collected by summing the rates of all annual fees charged
*
* @return Sum of annual fees charged
*/
public int chargeAnnualFees()
{
int totalAnnualFees = 0;
for (Account account : accounts)
{
if (account instanceof AnnualAcct || account instanceof CreditCard)
{
AnnualAcct accountWithAnnualFee = (AnnualAcct) account;
accountWithAnnualFee.chargeFee();
totalAnnualFees += accountWithAnnualFee.annualFee();
}
}
return totalAnnualFees;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment