### Question:
Polygon { public void addPoint(double x, double y) { if (npoints >= xpoints.length) { final int newLength = npoints * 2; xpoints = Arrays.copyOf(xpoints, newLength); ypoints = Arrays.copyOf(ypoints, newLength); } xpoints[npoints] = x; ypoints[npoints] = y; npoints++; updateBounds(); } Polygon(); void addPoint(double x, double y); void reset(); Area getArea(); boolean intersects(Area area); boolean contains(Area area); Collection<Line> getPoints(); @Override String toString();  }### Answer:
@Test void testAddPoint() { final Polygon polygon = new Polygon(); assertTrue(polygon.getPoints().isEmpty()); polygon.addPoint(1.0, 2.0); assertTrue(polygon.getPoints().isEmpty()); assertEquals(new Rectangle(0.0, 0.0, 0.0, 0.0), polygon.getArea()); polygon.addPoint(3.0, 4.0); assertEquals(new Line(1.0, 2.0, 3.0, 4.0), polygon.getPoints().iterator().next()); assertEquals(new Rectangle(0.0, 0.0, 0.0, 0.0), polygon.getArea()); polygon.addPoint(-1.0, -2.0); assertEquals(new Line(1.0, 2.0, 3.0, 4.0), polygon.getPoints().iterator().next()); assertEquals(new Rectangle(0.0, 0.0, 0.0, 0.0), polygon.getArea()); polygon.addPoint(-3.0, -4.0); assertEquals(new Rectangle(-3.0, -4.0, 6.0, 8.0), polygon.getArea()); }