|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--PrintSuperClass
|
+--Coordinates
Used to check, create and move the board location row,column;
Uses the constants Board.MAXROWS and Board.MAXCOLS
since board can have multiple coordinates, and since a coordinate may not always be tied to a board didn't use inheritance
Board| Field Summary | |
int |
col
public variables a Coordinates is row, column |
int |
row
public variables a Coordinates is row, column |
| Constructor Summary | |
Coordinates()
|
|
Coordinates(Coordinates c)
|
|
Coordinates(int i)
sets Coordinate to the i where i = row*MAXCOLS + col |
|
Coordinates(int r,
int c)
|
|
| Method Summary | |
void |
copy(Coordinates c)
|
int |
distance(Coordinates c)
computes the horizontal or vertical distance between two points |
boolean |
down()
takes current coordinate object and moves is down one row |
boolean |
equals(Coordinates c)
|
boolean |
isLegal()
|
boolean |
isLegalCol()
|
boolean |
isLegalRow()
|
boolean |
left()
takes current coordinate object and moves it left one coordinate |
Coordinates |
max(Coordinates c)
|
Coordinates |
min(Coordinates c)
|
Coordinates |
next()
takes current coordinate object and moves it to the next location when coordinate reaches end of board is starts over at 0,0 |
void |
print(java.io.PrintWriter pw)
|
void |
println(java.io.PrintWriter pw)
|
boolean |
right()
takes current coordinate object and moves it right one coordinate |
Coordinates |
set(Coordinates c)
sets current Coordinate object to location c |
Coordinates |
set(int i)
sets current Coordinate object to singleton i where i = row*MAXCOLS + col |
Coordinates |
set(int r,
int c)
sets current Coordinate object to r, c |
Coordinates |
setLegal(int r,
int c)
sets Coordinate object's row and col to the closest boards legal values of r, c |
int |
singleton()
|
java.lang.String |
toString()
|
boolean |
up()
takes current coordinate object and moves it up one row |
| Methods inherited from class PrintSuperClass |
print, print, print, println, println, println |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int row
public int col
| Constructor Detail |
public Coordinates()
public Coordinates(int r,
int c)
public Coordinates(Coordinates c)
public Coordinates(int i)
| Method Detail |
public java.lang.String toString()
toString in class java.lang.Objectpublic void print(java.io.PrintWriter pw)
print in class PrintSuperClasspublic void println(java.io.PrintWriter pw)
println in class PrintSuperClasspublic void copy(Coordinates c)
public Coordinates set(int r,
int c)
public Coordinates set(Coordinates c)
public Coordinates set(int i)
public Coordinates setLegal(int r,
int c)
public boolean up()
public boolean down()
public boolean left()
public boolean right()
public Coordinates next()
public boolean isLegalRow()
public boolean isLegalCol()
public boolean isLegal()
public int singleton()
public Coordinates max(Coordinates c)
public Coordinates min(Coordinates c)
public int distance(Coordinates c)
Limitation: Doesn't compute diagonal distance
public boolean equals(Coordinates c)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||