cse1030.drawing

Class Point2D

• ```public final class Point2D
extends Object```
A class that represents two dimensional points. A `Point2D` has an x and a y coordinate.
Author:
CSE1030Z
• Constructor Summary

Constructors
Constructor and Description
`Point2D()`
Creates a point with coordinates `(0.0, 0.0)`.
```Point2D(double x, double y)```
Creates a point with coordinates `(x, y)`.
`Point2D(Point2D other)`
Creates a point that has the same coordinates as another point.
• Method Summary

Methods
Modifier and Type Method and Description
`boolean` `equals(Object obj)`
Compare this point to another object for equality.
`double` `getX()`
Get the x coordinate point.
`double` `getY()`
Get the y coordinate of the point.
`int` `hashCode()`
Computes a hash code for this point.
`void` `setX(double x)`
Set the x coordinate of the point.
`void` `setY(double y)`
Set the y coordinate of the point.
`String` `toString()`
Returns a string representation of the point.
• Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• Constructor Detail

• Point2D

`public Point2D()`
Creates a point with coordinates `(0.0, 0.0)`.
• Point2D

`public Point2D(Point2D other)`
Creates a point that has the same coordinates as another point.
Parameters:
`other` - the `Point2D` object to copy
• Point2D

```public Point2D(double x,
double y)```
Creates a point with coordinates `(x, y)`.
• Method Detail

• getX

`public double getX()`
Get the x coordinate point.
Returns:
the x coordinate of the point
• setX

`public void setX(double x)`
Set the x coordinate of the point.
Parameters:
`x` - the new value for the x coordinate
• getY

`public double getY()`
Get the y coordinate of the point.
Returns:
the y coordinate of the point
• setY

`public void setY(double y)`
Set the y coordinate of the point.
Parameters:
`y` - the new value for the y coordinate
• hashCode

`public int hashCode()`
Computes a hash code for this point.
Overrides:
`hashCode` in class `Object`
Returns:
a hash code for this point
• equals

`public boolean equals(Object obj)`
Compare this point to another object for equality. The result is `true` if and only if the argument is not `null` and is a `Point2D` object having the same coordinates as this point.
Overrides:
`equals` in class `Object`
Parameters:
`obj` - the object to compare this point against
Returns:
`true` if the given object represents a `Point2D` equivalent to this point, `false` otherwise
• toString

`public String toString()`
Returns a string representation of the point. The returned string has the form:

`(X, Y)` where `X` is the x coordinate of the point and `Y` is the y coordinate of the point.

Overrides:
`toString` in class `Object`
Returns:
a string representation of the point