Point implements Serializable { public static Point add(Point p1, Point p2) { return new Point(p1.x + p2.x, p1.y + p2.y); } Point(double pX, double pY); static double distance(Point p1, Point p2); static Point add(Point p1, Point p2); static Point diff(Point p1, Point p2); static Point multiply(Point p, double d); static Point divide(Point p, double d); static Point centroid(Iterable<Point> points); static Point parsePoint(String pointString); @Override int hashCode(); @Override boolean equals(@Nullable Object other); @Override String toString(); final double x; final double y; }
@Test public void testAdd() { final Point p1 = new Point(1, 2); final Point p2 = new Point(3, 4); final Point result = Point.add(p1, p2); assertEquals(new Point(4, 6), result); }