Ejemplo n.º 1
0
 private int getTotalFrequentRenterPoints() {
   int result = 0;
   for (Rental rental : rentals) {
     result += rental.getFrequentRenterPoints();
   }
   return result;
 }
Ejemplo n.º 2
0
 /**
  * _rentals.elements().nextElement() getCharge() getFrequentRenterPoints() getMovie() getTitle()
  */
 public String statement() { // O(n)
   double totalAmount = 0;
   int frequentRenterPoints = 0;
   String result = "Rental Record for " + getName() + "\n";
   Enumeration<Rental> rentals = _rentals.elements();
   while (rentals.hasMoreElements()) {
     Rental each = rentals.nextElement();
     totalAmount += each.getCharge();
     frequentRenterPoints += each.getFrequentRenterPoints();
     result += "\t" + each.getMovie().getTitle() + "\t" + String.valueOf(each.getCharge()) + "\n";
   }
   result += "Amount owed is " + String.valueOf(totalAmount) + "\n";
   result += "You earned " + String.valueOf(frequentRenterPoints) + " frequent renter points";
   return result;
 }