Created
October 31, 2008 11:44
-
-
Save tatey/21288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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