Make your own free website on Tripod.com

Class Point

java.lang.Object
  |
  +--Point

public class Point
extends java.lang.Object

This class represents a Point as an x,y pair.


Field Summary
 double x
          Holds the x coordinate.
 double y
          Holds the y coordinate.
 
Constructor Summary
Point()
          Default class constructor creates a point at the origin.
Point(double x, double y)
          Class constructor creates a point at the given coordinate.
 
Method Summary
 void assign(double x, double y)
          Assigns the value of coordinates x and y to this point.
 void assign(Point pt)
          Assigns the value of pt to this point.
 double distance()
          Returns the distance of the point from the origin.
 double distance(Point pt)
          Returns the distance of pt from this point.
 java.lang.String toString()
          Method used by Java to convert from Point to string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
Holds the x coordinate.

y

public double y
Holds the y coordinate.
Constructor Detail

Point

public Point()
Default class constructor creates a point at the origin.
Parameters:
x - The x cooridinate.
y - The y cooridinate.

Point

public Point(double x,
             double y)
Class constructor creates a point at the given coordinate.
Parameters:
x - The x cooridinate.
y - The y cooridinate.
Method Detail

distance

public double distance()
Returns the distance of the point from the origin.
Returns:
A double that is the distance from the origin.

distance

public double distance(Point pt)
Returns the distance of pt from this point.
Returns:
A double that is the distance of pt from this point.

assign

public void assign(double x,
                   double y)
Assigns the value of coordinates x and y to this point.

assign

public void assign(Point pt)
Assigns the value of pt to this point.

toString

public java.lang.String toString()
Method used by Java to convert from Point to string. Useful when debugging.
Overrides:
toString in class java.lang.Object
Returns:
A String that is used when printing Point.