Class Point

java.lang.Object
  |
  +--Point

public class Point
extends java.lang.Object

The Point class is used to represent a point in some two-dimenstion space, the axes of which are labeled here as x and y. Each point also has a constant name, so that the points may be reassigned x / y values.

There is a class method called distance, which computes the euclidean distance between two Point instances, using the java.lang.Math class. Bugs: none known

See Also:
Main.java

Constructor Summary
Point(java.lang.String name)
          A constructor in which to specify just the name.
Point(java.lang.String name, int startX, int startY)
          A constructor in which to specify all three data members at once.
Point(java.lang.String name, Point source)
          A copy constructor, in which to specify the name of the new point, and a point whose coordinates to copy into this
 
Method Summary
static double distance(Point a, Point b)
          A public class method that returns the euclidean distance between two point instances.
 java.lang.String getName()
          An accessor for the data name
 int getX()
          An accessor for the x-coordiante
 int getY()
          An accessor for the y-coordinate
 void setX(int newX)
          A mutator for the x-coordiante
 void setY(int newY)
          A mutator for the y-coordiante
 java.lang.String toString()
          The method inherited from Object and overriden here to give an informative String about the instance at hand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point(java.lang.String name)
A constructor in which to specify just the name. The other values are given their default values according to their primitive types.

Parameters:
name - The name of the point

Point

public Point(java.lang.String name,
             int startX,
             int startY)
A constructor in which to specify all three data members at once. Uses the "this" reference to call the first constructor.

Parameters:
name - The name of the point, gets passed to the first constructor
startX - The initial x-coordinate of the point
startY - The initial y-coordinate of the point

Point

public Point(java.lang.String name,
             Point source)
A copy constructor, in which to specify the name of the new point, and a point whose coordinates to copy into this

Parameters:
name - The name of the point
source - The source Point whose coordinates to copy
Method Detail

getName

public java.lang.String getName()
An accessor for the data name

Returns:
The name of the point

getX

public int getX()
An accessor for the x-coordiante

Returns:
The value of the x-coordinate

getY

public int getY()
An accessor for the y-coordinate

Returns:
The value of the y-coordinate

setX

public void setX(int newX)
A mutator for the x-coordiante

Parameters:
newX - The new value for the x-coordinate

setY

public void setY(int newY)
A mutator for the y-coordiante

Parameters:
newY - The new value for the y-coordinate

distance

public static double distance(Point a,
                              Point b)
A public class method that returns the euclidean distance between two point instances. The euclidean distance metric is order-independent. Also note that while the method take in intergral point values, the return is necessarily a decimal.

Parameters:
a - One of the Points for the calculation
b - One of the Points for the calculation
Returns:
The decimal euclidean distance metric

toString

public java.lang.String toString()
The method inherited from Object and overriden here to give an informative String about the instance at hand

Overrides:
toString in class java.lang.Object
Returns:
An informative String about "this" instance