Created
July 2, 2011 09:23
-
-
Save philipschwarz/1059890 to your computer and use it in GitHub Desktop.
Before applying "Replace Temp With Query" to totalAmount
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
public String statement() | |
{ | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration<Rental> allRentals = rentals.elements(); | |
String result = "Rental record for " + getName() + "\n"; | |
while (allRentals.hasMoreElements()) | |
{ | |
Rental each = (Rental) allRentals.nextElement(); | |
frequentRenterPoints += each.getFrequentRenterPoints(); | |
// show figures for this rental | |
result += "\t" + each.getMovie().getTitle() + "\t" + String.valueOf(each.getCharge()) + "\n"; | |
totalAmount += each.getCharge(); | |
} | |
// add footer lines | |
result += "Amount owed is " + String.valueOf(totalAmount) + "\n"; | |
result += "You earned " + frequentRenterPoints + " frequent renter points"; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment