|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Point
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
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 |
public Point(java.lang.String name)
name
- The name of the pointpublic Point(java.lang.String name, int startX, int startY)
name
- The name of the point, gets passed to the first constructorstartX
- The initial x-coordinate of the pointstartY
- The initial y-coordinate of the pointpublic Point(java.lang.String name, Point source)
name
- The name of the pointsource
- The source Point whose coordinates to copyMethod Detail |
public java.lang.String getName()
public int getX()
public int getY()
public void setX(int newX)
newX
- The new value for the x-coordinatepublic void setY(int newY)
newY
- The new value for the y-coordinatepublic static double distance(Point a, Point b)
a
- One of the Points for the calculationb
- One of the Points for the calculation
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |