The `Point`

class offers methods for performing common geometry operations on two dimensional points.

## Method overview

`Point add(x, y);` |

`Point add(Point);` |

`Point clone();` |

`boolean equals(x, y);` |

`boolean equals(Point);` |

`boolean isZero();` |

`Point map(mapFunction);` |

`Point scale(scaleFactor);` |

`Point set(x, y);` |

`Point set(Point);` |

`Point subtract(x, y);` |

`Point subtract(Point);` |

`String toString();` |

## Constructor

Creates a new `Point`

object.

let p = new Point(x, y);

The new point, `p`

, has the specified X and Y coordinates.

## Methods

### add()

Adds another point to this one.

Point add( x, y ); Point add( Point );

###### Parameters

`x`

- The X coordinate of the point to add to the current point.
`y`

- The Y coordinate of the point to add to the current point.

**Note:**You may specify another

`Point`

object instead of separate X and Y coordinates.###### Return value

The value of the `Point`

object after adding the specified value; this isn't a new object, just the same one you called the function on.

### clone()

Creates and returns a copy of the `Point`

object.

Point clone();

###### Parameters

None.

###### Return value

A new `Point`

object which is a duplicate of the current object.

### equals()

Determines whether another point is equal to this one.

boolean equals( x, y ); boolean equals( Point );

###### Parameters

`x`

- The X coordinate of the point to compare to the current point.
`y`

- The Y coordinate of the point to compare to the current point.

**Note:**You may specify another

`Point`

object instead of separate X and Y coordinates.###### Return value

`true`

if the two points are equal, otherwise `false`

. Equality, in this context, means that both the X and Y coordinates are the same.

### isZero()

Determines whether or not the point is (0, 0).

boolean isZero();

###### Parameters

None.

###### Return value

`true`

if the point's X and Y coordinates are both zero; otherwise `false`

.

### map()

Calls a specified function to manipulate the values of the point's coordinates.

Point map( mapFunction );

###### Parameters

`mapFunction`

- The function to call to map the parameters; this function should accept one parameters: a single coordinate value. The
`Point`

object will be the value of`this`

within the called function.

###### Return value

The value of the `Point`

object after modifying its coordinates by calling the specified function; this isn't a new object, just the same one you called the function on.

### scale()

Scales the point's coordinates by a specified factor.

Point scale( scaleFactor );

###### Parameters

`scaleFactor`

- The amount by which to scale the point.

###### Return value

The value of the `Point`

object after scaling its coordinates by the specified amount; this isn't a new object, just the same one you called the function on.

### set()

Sets the value of the `Point`

object.

Point set( x, y ); Point set( Point );

###### Parameters

`x`

- The X coordinate of the point.
`y`

- The Y coordinate of the point.

**Note:**You may specify another

`Point`

object instead of separate X and Y coordinates.###### Return value

The `Point`

object.

### subtract()

Subtracts another point from this one.

Point subtract( x, y ); Point subtract( Point );

###### Parameters

`x`

- The X coordinate of the point to subtract from the current point.
`y`

- The Y coordinate of the point to subtract from the current point.

**Note:**You may specify another

`Point`

object instead of separate X and Y coordinates.###### Return value

The value of the `Point`

object after subtracting the specified value; this isn't a new object, just the same one you called the function on.

### toString()

Returns a string representation of the `Point`

object.

String toString();

###### Parameters

None.

###### Return value

A `String`

object representing the point, in "(*x*,*y*)" format.