Class Point

java.lang.Object
  |
  +--Point

public class Point
extends java.lang.Object

This class defines points on a standard Cartesian (XY) plane.


Constructor Summary
Point()
          Create a point at the origin (x = y = 0).
Point(double x, double y)
          Create a point at the specified coordinate.
 
Method Summary
 double distanceFrom(Point p)
          Determine the distance between two points
 double distanceFromOrigin()
          Determine the distance between the origin and the point.
 double getX()
          Retrieve the X coordinate of the point.
 double getY()
          Retrieve the Y coordinate of the point.
 void setX(double x)
          Change the X coordinate of the point.
 void setY(double y)
          Change the Y coordinate of the point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Point

public Point()
Create a point at the origin (x = y = 0).

Point

public Point(double x,
             double y)
Create a point at the specified coordinate.
Parameters:
x - The X coordinate
y - The Y coordinate
Method Detail

setX

public void setX(double x)
Change the X coordinate of the point.
Parameters:
x - The new X coordinate

setY

public void setY(double y)
Change the Y coordinate of the point.
Parameters:
y - The new Y coordinate

getX

public double getX()
Retrieve the X coordinate of the point.
Returns:
The X coordinate of the point

getY

public double getY()
Retrieve the Y coordinate of the point.
Returns:
The Y coordinate of the point

distanceFromOrigin

public double distanceFromOrigin()
Determine the distance between the origin and the point.
Returns:
The distance between the point and the origin

distanceFrom

public double distanceFrom(Point p)
Determine the distance between two points
Parameters:
p - The point to determine the distance from
Returns:
The distance between the two points