### Question:
Vector2D { public Vector2D translated(Vector2D offset) { Vector2D vector = copy(); vector.translate(offset); return vector; } Vector2D(double x, double y); double getX(); double getY(); void translate(Vector2D offset); Vector2D translated(Vector2D offset); void rotate(double angle); Vector2D rotated(double angle); void scale(double scaler); Vector2D scaled(double scaler); Vector2D copy(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test void testConstructor() { var vector1 = new Vector2D(5, 10); var vector2 = new Vector2D(0, 0).translated(vector1); assertEquals(vector1, vector2); }
@Test void testTranslated() { assertEquals(new Vector2D(-5, -10), new Vector2D(5, 10).translated(new Vector2D(-10, -20))); }
@Test void testTranslatedByNull() { assertThrows(NullPointerException.class, () -> new Vector2D(1, 2).translated(null)); }