### Question:
Segment implements Iterable<Map.Entry<Div, Rectangle>>, Iterator<Map.Entry<Div, Rectangle>> { public boolean tryAdd(Div div) { if (div == null) { return true; } if (this.remainWidth == 0) { return false; } AFloat aFloat = div.getFloat(); Rectangle blockSize = div.doPrepare(this.width); if (blockSize.getWidth() > this.remainWidth) { return false; } if (div.isBlockElement()) { if (!isEmpty()) { return false; } this.remainWidth = 0; add(div, blockSize); return true; } if (aFloat == AFloat.center && !isCenterFloat()) { return false; } Clear clear = div.getClear(); if (clear == Clear.left || clear == Clear.right) { for (Div inner : content) { if (clear == Clear.left) { if (inner.getFloat() == AFloat.left) { return false; } } else { if (inner.getFloat() == AFloat.right) { return false; } } } } this.remainWidth -= blockSize.getWidth(); add(div, blockSize); return true; } Segment(double width); private  Segment(); double getHeight(); boolean tryAdd(Div div); boolean isBlockable(); boolean isEmpty(); boolean isRemainAreaFiller(); List<Div> getContent(); List<Rectangle> getSizeList(); @Override Iterator<Map.Entry<Div, Rectangle>> iterator(); @Override boolean hasNext(); @Override void remove(); double getWidth(); @Override Map.Entry<Div, Rectangle> next();  }### Answer:
@Test public void tryAdd() { Segment sgm = new Segment(138d); Assertions.assertTrue(sgm.tryAdd(new Div(70d, 70d))); Assertions.assertFalse(sgm.tryAdd(new Div(70d, 70d))); sgm = new Segment(138d); Assertions.assertTrue(sgm.tryAdd( new Div(50d, 10d) .setClear(Clear.none) )); Assertions.assertTrue(sgm.tryAdd( new Div(38d, 70d) .setClear(Clear.none) )); Assertions.assertEquals(sgm.getHeight(), 70); Assertions.assertFalse(sgm.tryAdd( new Div(55d, 70d) .setClear(Clear.none) )); Assertions.assertTrue(sgm.tryAdd( new Div(1d, 70d) .setClear(Clear.none) )); sgm = new Segment(138d); Assertions.assertTrue(sgm.tryAdd( new Div(50d, 10d) .setClear(Clear.none) )); Assertions.assertFalse(sgm.tryAdd( new Div(50d, 10d) .setClear(Clear.left) )); }