/** The Calculator class here makes use of the getValue() functions so that * it can determine the max and average of any kind of array in our program. */ public class Calculator { // Find out which element of some array has the max value. public Measureable getMaximum(Measureable [] array) { Measureable max = array[0]; for (int i = 1; i < array.length; ++i) { if (array[i].getValue() > max.getValue()) max = array[i]; } return max; } // Find the average value in an array. public double getAverage(Measureable [] array) { double sum = 0; for (int i = 0; i < array.length; ++i) sum += array[i].getValue(); return sum / array.length; } }