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 AmountFor(Rental rental) { double thisAmount = 0; switch(rental.Movie.PriceCode) { case MoviePriceCode.Regular: thisAmount += 2; if(rental.DaysRented > 2) thisAmount += (rental.DaysRented - 2) * 1.5; break; case MoviePriceCode.NewRelease: thisAmount += rental.DaysRented * 3; break; case MoviePriceCode.Childrens: thisAmount += 1.5; if(rental.DaysRented > 3) thisAmount += (rental.DaysRented - 3) * 1.5; break; } return thisAmount; } public string Statement { get { double totalAmount = 0.0; int frequentRenterPoints = 0; string result = "Rental Record for " + Name + "\r\n"; foreach(Rental rental in rentals) { double thisAmount = 0.0; thisAmount = AmountFor(rental); frequentRenterPoints++; if(rental.Movie.PriceCode == MoviePriceCode.NewRelease && rental.DaysRented > 1) frequentRenterPoints++; result += "\t" + rental.Movie.Title + "\t" + thisAmount.ToString() + "\r\n"; totalAmount += thisAmount; } result += "Amount owed is " + totalAmount + "\r\n"; result += "You earned " + frequentRenterPoints + " frequent renter points"; return result; } } } }