1  import java.awt.Rectangle;
  2  
  3  /**
  4     This program demonstrates the use of a Measurer.
  5  */
  6  public class MeasurerTester
  7  {
  8     public static void main(String[] args)
  9     {
 10        class AreaMeasurer implements Measurer
 11        {
 12           public double measure(Object anObject)
 13           {
 14              Rectangle aRectangle = (Rectangle) anObject;
 15              double area = aRectangle.getWidth() * aRectangle.getHeight();
 16              return area;
 17           }
 18        }
 19  
 20        Measurer areaMeas = new AreaMeasurer();
 21  
 22        Rectangle[] rects = new Rectangle[] 
 23           {
 24              new Rectangle(5, 10, 20, 30),
 25              new Rectangle(10, 20, 30, 40),
 26              new Rectangle(20, 30, 5, 15)
 27           };
 28  
 29        double averageArea = Data.average(rects, areaMeas);
 30        System.out.println("Average area: " + averageArea);
 31        System.out.println("Expected: 625");
 32     }
 33  }