/**
   This program demonstrates the string measurer.
*/
public class MeasurerDemo
{
   public static void main(String[] args)
   {
      String[] words = { "Mary", "had", "a", "little", "lamb" };
      Measurer strMeas = new StringMeasurer();
      System.out.println("Average length: " 
         + average(words, strMeas));
   }

   /**
      Computes the average of the measures of the given objects.
      @param objs an array of objects
      @param meas the measurer
      @return the average of the measures
   */
   public static double average(Object[] objs, Measurer meas)
   {
      if (objs.length == 0) return 0;
      double sum = 0;
      for (Object obj : objs)
      {
         sum = sum + meas.measure(obj);
      }
      return sum / objs.length;
   }
}
