/** A repository of historical data which provides various kinds of statistics * on the data. * @author */ public class HistoricalData { // add some private fields to this class /** Initialize this HistoricalData object so that * it has no accumulated data. */ public HistoricalData() { // replace, if necessary, this comment with code, or delete it } /** Add a measurement to the accumulated data. * @param measurement The value of this measurement. */ public void add(double measurement) { return; // replace this line } /** Add each measurement in measurements to the accumulated data. * @param measurements The measurements to be added. */ public void addAll(double[] measurements) { return; // replace this line } /** Return the number of measurements stored in this * object's accumulated data. * @return int The number of elements stored. */ public int size() { return 0; // replace this line } /** Return the average of the accumulated data. * @return double The sum of the accumulated measurements divided by * the number of measurements. * @throws IllegalStateException When there are no measurements. */ public double average() throws IllegalStateException { return 0.0; // replace this line } /** Return the maximum value seen in the accumulated data. * @return double The maximum of the accumulated measurements. * @throws IllegalStateException When there are no measurements. */ public double max() throws IllegalStateException { return 0.0; // replace this line } /** Return a string representation of this object. * @see java.lang.Object#toString() */ public String toString() { int mySize = size(); return super.getClass().getName().toString() + "[" + mySize + ": " + (mySize > 0 ? Double.toString(average()) : "-") + "]"; } /** Return true if the argument is a HistoricalData object * with the same size, maximum, and average. * @see java.lang.Object#equals(Object) */ public boolean equals(Object oth) { return false; // replace this line } /** Return a hash code for this object. * @see java.lang.Object#hashCode() */ public int hashCode() { return 0; // replace this line } /** Return a clone of this object. * @see java.lang.Object#clone() */ public Object clone() { return null; // replace this line } // you can add any needed private methods here, or delete this comment }