Write an immutable Vector2
class with:
public final
instance variables for the two components, x
and y
.double
paramters to initialize x
and y
.toString()
method that returns a String
representation of a Vector2
that looks like (1, 2)
.plus
method that takes another Vector2
parameter and returns the Vector2
result of adding this Vector2
to the argument Vector2
. Vector addition is defined as: minus
method that takes another Vector2
parameter and returns the Vector2
result of subtracting the argument Vector2
object from this Vector2
. Vector subtraction is defined as: dot
method that takes another Vector2
parameter and returned the double
dot product of this Vector2
and the argument Vector2
. Dot product is defined as: