/** Test of MeasureUtil. Note that we could change the 
 *  actual classes of elements in the measurables array (as
 *  long as they implemented Measurable) without changing
 *  the rest of the code.
 *
 *  Taken from Core Web Programming from 
 *  Prentice Hall and Sun Microsystems Press,
 *  http://www.corewebprogramming.com/.
 *  &copy; 2001 Marty Hall and Larry Brown;
 *  may be freely used or adapted. 
 */

public class MeasureTest {
  public static void main(String[] args) {
    Measurable[] measurables =
      { new Rectangle(0, 0, 5.0, 10.0),
        new Rectangle(0, 0, 4.0, 9.0),
        new Circle(0, 0, 4.0),
        new Circle(0, 0, 5.0) };
    System.out.print("Areas:");
    for(int i=0; i<measurables.length; i++)
      System.out.print(" " + measurables[i].getArea());
    System.out.println();
    System.out.println("Larger of 1st, 3rd: " +
       MeasureUtil.maxArea(measurables[0],
                     measurables[2]) +
                     "\nTotal area: " +
                     MeasureUtil.totalArea(measurables));
  }
}