public class Movie { public static final int REGULAR = 0; public static final int NEW_RELEASE = 1; public static final int CHILDRENS = 2; private static final Price [] prices = { RegularPrice.PRICE, NewReleasePrice.PRICE, ChildrensPrice.PRICE }; private String _title; private Price _price; public Movie(String title,int priceCode) { _title=title; setPriceCode(priceCode); } public int getPriceCode() { return _price.getPriceCode(); } public void setPriceCode(int priceCode) { try { _price = prices[priceCode]; } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Incorrect Price Code"); } } public String getTitle() { return _title; } public int getFrequentRenterPoints(int daysRented) { return _price.getFrequentRenterPoints(daysRented); } public double getCharge(int daysRented) { return _price.getCharge(daysRented); } }