RollingAverage { private double peak() { return (size - 1) / 2d; } RollingAverage(final int size); synchronized double put(final double value); double average(); boolean reachedPeak(); String toS();  }
@Test public void peakTest() { RollingAverage avg1 = new RollingAverage(2); assertWithMessage("peak 2").that(avg1.getPeak()).isEqualTo(0.5d); avg1 = new RollingAverage(3); assertWithMessage("peak 3").that(avg1.getPeak()).isEqualTo(1d); avg1 = new RollingAverage(4); assertWithMessage("peak 4").that(avg1.getPeak()).isEqualTo(1.5d); avg1 = new RollingAverage(5); assertWithMessage("peak 5").that(avg1.getPeak()).isEqualTo(2d); }