public class Location
extends java.lang.Object
implements java.lang.Comparable
Location
object represents the row and column of a
location in a two-dimensional grid.
The Location
class is
copyright© 2002 College Entrance Examination Board
(www.collegeboard.com).
Constructor and Description |
---|
Location(int row,
int col)
Constructs a
Location object. |
Modifier and Type | Method and Description |
---|---|
int |
col()
Returns the column coordinate of this location.
|
int |
compareTo(java.lang.Object other)
Compares this location to
other for ordering. |
boolean |
equals(java.lang.Object other)
Indicates whether some other
Location object is
"equal to" this one. |
int |
hashCode()
Generates a hash code for this location
(will not be tested on the Advanced Placement exam).
|
int |
row()
Returns the row coordinate of this location.
|
java.lang.String |
toString()
Represents this location as a string.
|
public Location(int row, int col)
Location
object.row
- location's rowcol
- location's columnpublic int row()
public int col()
public boolean equals(java.lang.Object other)
Location
object is
"equal to" this one.equals
in class java.lang.Object
other
- the other location to testtrue
if other
is at the
same row and column as the current location;
false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object
Location
objectpublic int compareTo(java.lang.Object other)
other
for ordering.
Returns a negative integer, zero, or a positive integer as this
location is less than, equal to, or greater than other
.
Locations are ordered in row-major order.
(Precondition: other
is a Location
object.)compareTo
in interface java.lang.Comparable
other
- the other location to testother
, zero if the two locations are equal,
or a positive integer if this location is greater than
other
public java.lang.String toString()
toString
in class java.lang.Object