SimpleBoxMaker implements BoxMaker { @Override public <N extends Number & Comparable<N>> Box<N> make(Point<N> center, N radius) { N x0 = subtract(center.getX(), radius); N x1 = add(center.getX(), radius); N y0 = subtract(center.getY(), radius); N y1 = add(center.getY(), radius); Point<N> a = new Point<N>(min(x0, x1), min(y0, y1)); Point<N> b = new Point<N>(max(x0, x1), max(y0, y1)); return new Box<N>(a, b); }  @Override Box<N> make(Point<N> center, N radius);  }
@Test public void makeBox() { Box<Double> expected = new Box<Double>( new Point<Double>(p.getX() - radius, p.getY() - radius), new Point<Double>(p.getX() + radius, p.getY() + radius) ); assertEquals(expected, boxMaker.make(p, radius)); }
@Test public void makeBox_negativeRadius() { Box<Double> expected = new Box<Double>( new Point<Double>(p.getX() - radius, p.getY() - radius), new Point<Double>(p.getX() + radius, p.getY() + radius) ); assertEquals(expected, boxMaker.make(p, -radius)); }