### Question:
WindowCounter { public int getLastIndex() { return lastIndex; } WindowCounter(int capacity); int getLastIndex(); void record(int snapshot); int getHistory(); boolean allMatch(IntPredicate predicate);  }### Answer:
@Test public void testGetLastIndex() throws Exception { WindowCounter counter = new WindowCounter(5); counter.record(1); counter.record(1); counter.record(1); Assert.assertEquals(3, counter.getLastIndex()); counter.record(1); counter.record(1); counter.record(1); Assert.assertEquals(6, counter.getLastIndex()); }