/* The customer class represents the customer of the store. Like the * other classes it has data and accessors. Customer also has the * method that produces a statement. */ import java.util.*; class Customer { private String name; private ArrayList rentals = new ArrayList(); public Customer(String name) { this.name = name; } public void addRental(Rental arg) { rentals.add(arg); } public String getName() { return name; } public String statement() { double totalAmount = 0; int frequentRenterPoints = 0; String result = "Rental Record for " + getName() + "\n"; for (Rental rent: rentals) { double thisAmount = 0; thisAmount = rent.amountFor(); // add frequent renter points frequentRenterPoints++; // add bonus for a two day new release rental int code = rent.getMovie().getPriceCode(); if (code == Movie.NEW_RELEASE && rent.getDaysRented() > 1) frequentRenterPoints++; // show figures for this rental result += "\t" + rent.getMovie().getTitle() + "\t" + thisAmount + "\n"; totalAmount += thisAmount; } // add footer lines result += "Amount owed is " + totalAmount + "\n"; result += "You earned " + frequentRenterPoints + " frequent renter points"; return result; } }