Presentation is loading. Please wait.

Presentation is loading. Please wait.

private double amountFor(Rental aRental)

Similar presentations


Presentation on theme: "private double amountFor(Rental aRental)"— Presentation transcript:

1 private double amountFor(Rental aRental)
return aRental.getCharge(); } initially replace the body with the call remove this method later on and call directly while (rentals.hasMoreElements()) { double thisAmount = 0; Rental each = (Rental) rentals.nextElement(); thisAmount = each.getCharge(); … the rest continues as before

2 frequent renter points
Let’s do the same thing with the logic to calculate frequent renter points extract method each can be parameter frequentRenterPoints has a value before the method is invoked, but the new method does not read it; we simply need to use appending assignment outside the method. move method Again, we are only using information from Rental, not Customer, so let’s move getFrequentRenterPoints to the Rental class. Be sure to run your test cases after each step

3 // add frequent renter points
// add bonus for two day new release rental if ((each.getMovie().getPriceCode() == Movie.NEW_RELEASE) && each.getDaysRented() > 1) // show figures for this rental result += “\t” + each.getMovie().getTitle() + “\t” + String.valueOf(thisAmount) + “\n”; totalAmount += thisAmount; } // end while


Download ppt "private double amountFor(Rental aRental)"

Similar presentations


Ads by Google