Class Point2D

java.lang.Object
  extended by Point2D

public class Point2D
extends java.lang.Object

Utility class for managing points in 2D

Author:
C. D'Arcy

Constructor Summary
Point2D()
          Sets coordinates to (0.0, 0.0)
Point2D(double[] c)
          Sets coordinates to (c[0],c[1])
Point2D(double x, double y)
          Sets coordinates to (x,y)
 
Method Summary
 double getCoordinate(int i)
          Accessor method used to retrieve specific coordinate
 double[] getCoordinates()
          Accessor method used to retrieve coordinate array
 void setCoordinate(int i, double value)
          Modifier method allows client (or this) to set a new value for either coordinate
 void setCoordinates(double[] c)
          Sets coordinates to (c[0],c[1])
 void setCoordinates(Point2D other)
          Modifier methood that sets coordinates of this object to the same as the Point2D parameter
 void setLocation(double x, double y)
          Modifier method allows client (or this) to set new coordinates
 java.lang.String toString()
          Composes and returns meaningful string representation of the ordered pair
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point2D

public Point2D()
Sets coordinates to (0.0, 0.0)


Point2D

public Point2D(double x,
               double y)
Sets coordinates to (x,y)

Parameters:
x - the abscissa (x value)
y - the ordinate (y value)

Point2D

public Point2D(double[] c)
Sets coordinates to (c[0],c[1])

Parameters:
c - array containing the new coordinates
Method Detail

setLocation

public void setLocation(double x,
                        double y)
Modifier method allows client (or this) to set new coordinates

Parameters:
x - the new abscissa (x value)
y - the new ordinate (y value)

setCoordinate

public void setCoordinate(int i,
                          double value)
Modifier method allows client (or this) to set a new value for either coordinate

Parameters:
i - the index of the new coordinate (0 for x, 1 for y)
value - the new coordinate

setCoordinates

public void setCoordinates(double[] c)
Sets coordinates to (c[0],c[1])

Parameters:
c - array containing the new coordinates

setCoordinates

public void setCoordinates(Point2D other)
Modifier methood that sets coordinates of this object to the same as the Point2D parameter

Parameters:
other - Point2D object to be duplicated

getCoordinates

public double[] getCoordinates()
Accessor method used to retrieve coordinate array


getCoordinate

public double getCoordinate(int i)
Accessor method used to retrieve specific coordinate

Parameters:
i - the index of the coordinate to be retrieved (0 for x, 1 for y)

toString

public java.lang.String toString()
Composes and returns meaningful string representation of the ordered pair

Overrides:
toString in class java.lang.Object