1 public class Data
2 {
3 /**
4 Computes the average of the measures of the given objects.
5 @param objects an array of Measurable objects
6 @return the average of the measures
7 */
8 public static double average(Measurable[] objects)
9 {
10 double sum = 0;
11 for (Measurable obj : objects)
12 {
13 sum = sum + obj.getMeasure();
14 }
15 if (objects.length > 0) { return sum / objects.length; }
16 else { return 0; }
17 }
18 }