public class Customer { public static int MaximumRentals = 10; private String name; private Rental[] rentals; private int numberRented; public Customer( String name ) { this.name = name; this.rentals = new Rental[MaximumRentals]; numberRented = 0; } public void addRental( Rental r ) { if ( numberRented >= MaximumRentals ) return; rentals[numberRented] = r; numberRented++; } public String name() { return name; } public String statement() { double totalAmount = 0.0; int frequentRenterPoints = 0; String result = "Rental Record for " + name() + "\n"; for (int i=0; i < numberRented; i++) { Rental entry = rentals[i]; double amount = entry.price(); totalAmount = totalAmount + amount; frequentRenterPoints = frequentRenterPoints + entry.renterPoints(); // show figures for this rental result = result + "\t" + entry.movie().title() + "\t" + amount + "\n"; } // add footer lines result = result + "Amount owed is " + totalAmount + "\n" + "You earned " + frequentRenterPoints + " frequent renter points"; return result; } public String htmlStatement() { double totalAmount = 0.0; int frequentRenterPoints = 0; String result = "

Rental Record for " + name() + "

\n"; for (int i=0; i < numberRented; i++) { Rental entry = rentals[i]; double amount = entry.price(); totalAmount = totalAmount + amount; frequentRenterPoints = frequentRenterPoints + entry.renterPoints(); // show figures for this rental result = result + "\t" + entry.movie().title() + "\t" + amount + "
\n"; } // add footer lines result = result + "

Amount owed is " + totalAmount + "

\n" + "

You earned " + frequentRenterPoints + " frequent renter points

"; return result; } }