cse1030.drawing

Class IPoint2D

• public final class IPoint2D
extends Object
An immutable class that represents points on the real 2D plane. An IPoint2D as an x and a y coordinate.
Author:
CSE1030_F13_14
• Constructor Summary

Constructors
Constructor and Description
IPoint2D()
Constructs a point with coordinates (0.0, 0.0).
IPoint2D(double x, double y)
Constructs a point with coordinates (x, y).
• Method Summary

Methods
Modifier and Type Method and Description
double distanceTo(IPoint2D other)
Returns the distance between this point and another point.
boolean equals(Object obj)
Compares this point to another object.
double getX()
Returns the x coordinate of this point.
double getY()
Returns the y coordinate of this point.
String toString()
Returns a string containing the coordinates of the point separated by a space and a comma and inside round brackets.
• Constructor Detail

• IPoint2D

public IPoint2D()
Constructs a point with coordinates (0.0, 0.0).
• IPoint2D

public IPoint2D(double x,
double y)
Constructs a point with coordinates (x, y).
Parameters:
x - the x coordinate
y - the y coordinate
• Method Detail

• getX

public double getX()
Returns the x coordinate of this point.
Returns:
the x coordinate of this point
• getY

public double getY()
Returns the y coordinate of this point.
Returns:
the y coordinate of this point
• distanceTo

public double distanceTo(IPoint2D other)
Returns the distance between this point and another point.
Parameters:
other - the point to compute the distance to
Returns:
the distance between this point and other
• equals

public boolean equals(Object obj)
Compares this point to another object. The result is true if and only if the argument is not null and is an IPoint2 object that has the same coordinates of this object.
Overrides:
equals in class Object
Object.equals(java.lang.Object)
Parameters:
obj - the other object to compare
Returns:
true if obj is an IPoint2 object with the same coordinates as this object
• toString

public String toString()
Returns a string containing the coordinates of the point separated by a space and a comma and inside round brackets. No special formatting is applied to the coordinates. For example: (new IPoint2(-1.5, 3.1415)).toString() returns the string "(-1.5, 3.1415)".
Overrides:
toString in class Object