Implement a class Point
that represents a point in the plane, with accessors that yield
Points can be constructed in the following ways:
- With a no-argument constructor that constructs the origin (0, 0).
- With a constructor that takes the x- and y-component.
- With a constructor that takes an array of length 2 with the x- and y-coordinates.
- As a copy of another point.
- With factory methods
of
and ofPolar
.
Look at the unit test for details.
Hint: The angle is Math.atan2(y, x)
.