5 * $Id: Location.java,v 1.2 2008/04/11 17:53:12 rmh3093 Exp rmh3093 $
8 * $Log: Location.java,v $
9 * Revision 1.2 2008/04/11 17:53:12 rmh3093
12 * Revision 1.1 2008/03/31 03:58:55 rmh3093
18 * This class represents the location of a word in a word search puzzle. The
19 * location of a word is given as the coordinates of the first and last
20 * characters in the word. A coordinate consists of the row and column in the
21 * puzzle grid. Rows and columns are numbered from 0 to R-1 and C-1 respectively
22 * (where R and C are the number of rows and columns in the puzzle grid.
26 public class Location
{
28 int sRow
; //the row of the first character
29 int sCol
; //the column of the first character
30 int eRow
; //the row of the last character
31 int eCol
; //the column of the last character
34 * Create a location of [(0,0) (0,0)]
37 sRow
= sCol
= eRow
= eCol
= 0;
41 * Create a location of [(sRow,sCol) (eRow,eCol)]
43 * @param sRow the row of the first character
44 * @param sCol the column of the first character
45 * @param eRow the row of the last character
46 * @param eCol the column of the last character
48 public Location(int sRow
, int sCol
, int eRow
, int eCol
) {
56 * Return the row number in the puzzle that contains the first letter in
61 public int getStartRow() {
66 * Set the row number in the puzzle that contains the first letter in the
69 * @param sRow row containing the first letter of the word
71 public void setStartRow(int sRow
) {
76 * Return the column number in the puzzle that contains the first letter in
81 public int getStartCol() {
86 * Set the column number in the puzzle that contains the first letter in the word.
88 * @param sCol column containing the first letter of the word
90 public void setStartCol(int sCol
) {
95 * Return the row number in the puzzle that contains the last letter in the
100 public int getEndRow() {
105 * Set the row number in the puzzle that contains the last letter in the
108 * @param eRow row containing the last letter of the word
110 public void setEndRow(int eRow
) {
115 * Return the column number in the puzzle that contains the last letter in
120 public int getEndCol() {
125 * Set the column number in the puzzle that contains the last letter in the
128 * @param eCol column containing the last letter of the word
130 public void setEndCol(int eCol
) {
135 * Convert this Location to a string. The string must adhere to the
136 * following format: [(startRow,startCol) (endRow,endCol)]
138 public String
toString() {
139 return "[(" + sRow
+ "," + sCol
+ ") (" + eRow
+ "," + eCol
+ ")]";
143 * Compare this Location to the Location given as an argument. The result is
144 * true if and only if the argument is not null and it represents the same
145 * location as this object. Two locations are the same if their startRow,
146 * startCol, endRow, and endCol are the same.
151 public boolean equals(Location other
) {
154 if (this.eCol
== other
.getEndCol()) {
155 if (this.eRow
== other
.getEndRow()) {
156 if (this.sCol
== other
.getStartCol()) {
157 if (this.sRow
== other
.getStartRow()) {