using System; using System.Collections; namespace BlockBuster { public class Customer { public Customer(string name) { this.name = name; } private string name; public string Name { get { return name; } } private ArrayList rentals = new ArrayList(); public void AddRental(Rental rental) { rentals.Add(rental); } private double TotalCharge { get { double result = 0.0; foreach(Rental rental in rentals) { result += rental.Charge; } return result; } } private int TotalFrequentRenterPoints { get { int result = 0; foreach(Rental rental in rentals) { result += rental.FrequentRenterPoints; } return result; } } public string Statement { get { string result = "Rental Record for " + Name + "\r\n"; foreach(Rental rental in rentals) { result += "\t" + rental.Movie.Title + "\t" + rental.Charge.ToString() + "\r\n"; } result += "Amount owed is " + TotalCharge + "\r\n"; result += "You earned " + TotalFrequentRenterPoints + " frequent renter points"; return result; } } public string HtmlStatement { get { String result = "

Rentals for " + Name + "

"; foreach(Rental rental in rentals) { result += rental.Movie.Title + ": " + rental.Charge + "
\n"; } result += "

You owe " + TotalCharge + "

\n"; result += "On this rental you earned " + TotalFrequentRenterPoints + " frequent renter points

"; return result; } } } }