MeasurerTester.java.html

  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        Measurer areaMeas = new AreaMeasurer();
 11  
 12        Rectangle[] rects = new Rectangle[] 
 13           {
 14              new Rectangle(5, 10, 20, 30),
 15              new Rectangle(10, 20, 30, 40),
 16              new Rectangle(20, 30, 5, 15)
 17           };
 18  
 19        double averageArea = Data.average(rects, areaMeas);
 20        System.out.println("Average area: " + averageArea);
 21        System.out.println("Expected: 625");
 22     }
 23  }