Skip to content

Instantly share code, notes, and snippets.



Created Oct 31, 2008
What would you like to do?
* 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;
totalAnnualFees += accountWithAnnualFee.annualFee();
return totalAnnualFees;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment