@Test public void segment_size() { FileSegmenter segmenter = new FileSegmenter(Paths.get("base"), 10, 100); assertThat("starts at initial size", segmenter.sizeOf(0), is(10)); assertThat("doubles for next segment", segmenter.sizeOf(1), is(20)); assertThat("doubles for next segment", segmenter.sizeOf(2), is(40)); assertThat("never goes over max size", segmenter.sizeOf(10), is(100)); }
public int sizeOf(int segment) { int size = initialSize; for (int i = 0; i < segment; i++) { size *= 2; if (size > maxSize) { return maxSize; } } return size; }
FileSegmenter { public int sizeOf(int segment) { int size = initialSize; for (int i = 0; i < segment; i++) { size *= 2; if (size > maxSize) { return maxSize; } } return size; } }
FileSegmenter { public int sizeOf(int segment) { int size = initialSize; for (int i = 0; i < segment; i++) { size *= 2; if (size > maxSize) { return maxSize; } } return size; } FileSegmenter(Path base, int initialSize, int maxSize); }
FileSegmenter { public int sizeOf(int segment) { int size = initialSize; for (int i = 0; i < segment; i++) { size *= 2; if (size > maxSize) { return maxSize; } } return size; } FileSegmenter(Path base, int initialSize, int maxSize); Path pathOf(int segment); int sizeOf(int segment); }
FileSegmenter { public int sizeOf(int segment) { int size = initialSize; for (int i = 0; i < segment; i++) { size *= 2; if (size > maxSize) { return maxSize; } } return size; } FileSegmenter(Path base, int initialSize, int maxSize); Path pathOf(int segment); int sizeOf(int segment);  }