Class Point

java.lang.Object
  extended by Point

public class Point
extends java.lang.Object

Final draft of the Point class for a 2D mathematical point. Created in class on Jan 26, improved on Jan 31, and finished Feb 2.


Constructor Summary
Point()
          Default constructor.
Point(int x, int y)
          Point Constructor with initialization
 
Method Summary
 double distanceBetween(Point otherPoint)
          Compute 2D distance between this and otherPoint.
 double distanceTo()
          Compute 2D distance from origin to point.
 int getX()
          Get the X value of the point
 int getY()
          Get the Y value of the point
 void setPosition(int x, int y)
          Set the position of the point
 void translate(int deltaX, int deltaY)
          Translate the point to a new location
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Point

public Point()
Default constructor.


Point

public Point(int x,
             int y)
Point Constructor with initialization

Parameters:
x - initial X location of point
y - initial Y location of point
Method Detail

setPosition

public void setPosition(int x,
                        int y)
Set the position of the point

Parameters:
x - new X position
y - new Y position

translate

public void translate(int deltaX,
                      int deltaY)
Translate the point to a new location

Parameters:
deltaX - amount to move in X
deltaY - amount to move in Y

getX

public int getX()
Get the X value of the point

Returns:
X coordinate of point

getY

public int getY()
Get the Y value of the point

Returns:
Y coordinate of point

distanceTo

public double distanceTo()
Compute 2D distance from origin to point.


distanceBetween

public double distanceBetween(Point otherPoint)
Compute 2D distance between this and otherPoint.

Parameters:
otherPoint - second point in distance calculation