import java.io.*;
import java.lang.*;
public class WordSearch extends Object {
Puzzle thePuzzle;
String[] theWords;
public WordSearch() {
}
// main class
public static void main( String[] args ) {
if( args.length == 1 ){
try{
Scanner input = new Scanner( new File( args[0] ) );
while(input.hasNext()) {
System.out.println(input.nextLine());
}
} catch( IOException e ) {
}
}
}
} // WordSearch
______________________________________________________-
public class Puzzle {
private char[][] puzzleGrid;
// Load a puzzle from a puzzle file
public Puzzle( String puzzleFile ) throws PuzzleFileFormatException {
}
// Search the puzzle for the given string. The search is not case sensitive
// and any non-alphabetic characters in the string will be ignored. If the
// string is found in the puzzle a location object, describing where the
// string was found will be returned. If the string is not found in the
// puzzle, null will be returned. (adding this later)
// Print the puzzle contained in this object to standard output
public void print() {
System.out.println( );
}
// Replace the puzzle currently stored in this object with the puzzle
// contained in the given file
public void setPuzzle( String puzzleFile )
throws PuzzleFileFormatException {
}
} // Puzzle
________________________________________________________________
public class Location {
/**
* This class represents the location of a word in a word search puzzle. The
* location of a word is given as the coordinates of the first and last
* characters in the word. A coordinate consists of the row and column in the
* puzzle grid. Rows and columns are numbered from 0 to R-1 and C-1
* respectively ( where R and C are the number of rows and columns in the
* puzzle grid.
*/
private int startR;
private int endR;
private int startC;
private int endC;
// Create a location of [( 0, 0 ) ( 0, 0 )]
public Location() {
}
// Create a location of [( sRow, sCol ) ( eRow, eCol )]
public Location( int sRow, int sCol, int eRow, int eCol ) {
startR = sRow;
endR = eRow;
startC = sCol;
endC = eCol;
}
// Compare this Location to the Location given as an argument
public boolean equals( Location other ) {
if( startR == other.getStartRow() && startC == other.getStartCol() &&
endR == other.getEndRow() && endC == other.getEndCol() ) {
return true;
} else {
return false;
}
}
// Return the column number in the puzzle that contains the last letter
public int getEndCol() {
return endC;
}
// Return the row number in the puzzle that contains the last letter
public int getEndRow() {
return endR;
}
// Return the column number in the puzzle that contains the first letter
public int getStartCol() {
return startC;
}
// Return the row number in the puzzle that contains the first letter
public int getStartRow() {
return startR;
}
// Set the column number in the puzzle that contains the last letter
public void setEndCol( int eCol ) {
endC = eCol;
}
// Set the row number in the puzzle that contains the last letter
public void setEndRow( int eRow ) {
endR = eRow;
}
// Set the column number in the puzzle that contains the first letter
public void setStartCol( int sCol ) {
startC = sCol;
}
// Set the row number in the puzzle that contains the first letter
public void setStartRow( int sRow ) {
startR = sRow;
}
// Convert this Location to a string
public String toString() {
return "Word Search";
}
} //Location
___________________________________________
import java.io.Serializable;
public class PuzzleFileFormatException extends Exception
implements Serializable {
/**
* This exception is thrown when an invalid puzzle file is processed. A
* file can be declared invalid for any one of the following reasions:
* -the fow is not a number
* -the column is not a number
* -the number of lines in the puzzle doesn't equal the row number
* -the length of any line in the puzzle is greater than the column number
*/
public PuzzleFileFormatException( String msg ) {
super( msg );
}
} // PuzzleFileFormatException