@Test void testAverage() { try { assertEquals(1007.00/4, calculator.average(), .01); } catch (NoElementsException e) { fail("Caught NoElementsException"); e.printStackTrace(); } }
public Double average() throws NoElementsException { Double total = 0.0; if(values.isEmpty()) { throw new NoElementsException(); } for (Double value : values) { total += value; } return total/(double)values.size(); }
Calculator { public Double average() throws NoElementsException { Double total = 0.0; if(values.isEmpty()) { throw new NoElementsException(); } for (Double value : values) { total += value; } return total/(double)values.size(); } }
Calculator { public Double average() throws NoElementsException { Double total = 0.0; if(values.isEmpty()) { throw new NoElementsException(); } for (Double value : values) { total += value; } return total/(double)values.size(); } Calculator(); }
Calculator { public Double average() throws NoElementsException { Double total = 0.0; if(values.isEmpty()) { throw new NoElementsException(); } for (Double value : values) { total += value; } return total/(double)values.size(); } Calculator(); void add(Double value); Double average(); Double median(); }
Calculator { public Double average() throws NoElementsException { Double total = 0.0; if(values.isEmpty()) { throw new NoElementsException(); } for (Double value : values) { total += value; } return total/(double)values.size(); } Calculator(); void add(Double value); Double average(); Double median();  }