### Question:
PieChart { static Point2D calculateEndPoint(double radius, double centerX, double centerY, double ratio) { if (ratio > 1) { ratio = 1.0; } double radians = ratio * 2 * Math.PI; double x = radius * (1 + Math.sin(radians)); double y = radius * (1 - Math.cos(radians)); return new Point2D.Double(x + centerX - radius, y + centerY - radius); }  static double calculateEndPointX(
      double radius, double centerX, double centerY, double ratio); static double calculateEndPointY(
      double radius, double centerX, double centerY, double ratio);  }### Answer:
@Test public void testRightAngle() { Point2D actual = PieChart.calculateEndPoint(100, 100, 100, .25); Point2D expected = new Point2D.Double(200, 100); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testZero() { Point2D actual = PieChart.calculateEndPoint(100, 100, 100, 0); Point2D expected = new Point2D.Double(100, 0); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testOneEighth() { int radius = 100; double ratio = 1.0/8.0; Point2D actual = PieChart.calculateEndPoint(radius, 100, 100, ratio); Point2D expected = new Point2D.Double(100 + 100 / Math.sqrt(2), 100 - 100 / Math.sqrt(2)); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testHalf() { Point2D actual = PieChart.calculateEndPoint(100, 100, 100, 0.5); Point2D expected = new Point2D.Double(100, 200); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testOffCenter() { Point2D actual = PieChart.calculateEndPoint(150, 150, 100, 0.5); Point2D expected = new Point2D.Double(150, 250); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testFull() { Point2D actual = PieChart.calculateEndPoint(100, 100, 100, 1.0); Point2D expected = new Point2D.Double(100, 0); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }
@Test public void testMoreThanFull() { Point2D actual = PieChart.calculateEndPoint(100, 100, 100, 5.5); Point2D expected = new Point2D.Double(100, 0); Assert.assertEquals(expected.getX(), actual.getX(), TOLERANCE); Assert.assertEquals(expected.getY(), actual.getY(), TOLERANCE); }