OverviewScheduleResourcesAssignmentsHome

CSC 122: Computer Science II, Fall 2005

Project 2

Sorting and Searching - Word Search

Deadline: Wednesday, September 21, 5:00 p.m.

Overview:
You are to write a program that solves word search puzzles by listing all of the words that can be found in a grid (forwards, backwards, up, down, or diagonally) that are also in a large (around 100,000 words) list of English words. You have been provided with a Grid class that can either generate a random grid or read one from a text file (using the same Infile class from Project 1). You are to write a word list class to read in the dictionary from a text file, sort it, and support efficient searching. You will also write a driver class which creates a grid and a word list, then prints out the grid followed by all of the dictionary words that were found in the grid. You do not need to mark where the words were found in the grid.
Specification:
Here is an excerpt from the JavaDoc for the provided Grid class:
public class Grid

Stores a two-dimensional grid of characters for use in a word search game. The grid may be generated randomly or read from a file.

Author:
bhoward

Constructor Summary
Grid(Infile in)
          Construct a Grid by reading lines from a text file.
Grid(int rows, int cols)
          Construct a randomly-generated Grid of the given size.
 
Method Summary
 java.lang.String chars(int row, int col, int dir)
          Extract characters from this Grid starting at the given row and column and heading in the given direction: 0 is right, 1 is down-right, 2 is down, 3 is down-left, 4 is left, 5 is up-left, 6 is up, and 7 is up-right.
 int cols()
          Get the number of columns in this Grid.
 void display()
          Print this Grid on the system console.
 int rows()
          Get the number of rows in this Grid.
 
Constructor Detail

Grid

public Grid(Infile in)
Construct a Grid by reading lines from a text file.
Parameters:
in - The Infile from which to read. The number of rows will be the number of lines read from the file; the number of columns will be the number of characters in the shortest line (longer lines will be truncated).

Grid

public Grid(int rows,
            int cols)
Construct a randomly-generated Grid of the given size.
Parameters:
rows -
cols -
Method Detail

chars

public java.lang.String chars(int row,
                              int col,
                              int dir)
Extract characters from this Grid starting at the given row and column and heading in the given direction: 0 is right, 1 is down-right, 2 is down, 3 is down-left, 4 is left, 5 is up-left, 6 is up, and 7 is up-right.
Parameters:
row - The starting row (0 .. rows()-1)
col - The starting column (0 .. cols()-1)
dir - The direction (0 .. 7)
Returns:
The string of characters from the starting position to an edge of the grid.

cols

public int cols()
Get the number of columns in this Grid.

display

public void display()
Print this Grid on the system console.

rows

public int rows()
Get the number of rows in this Grid.

Word list format:

The suggested algorithm:


The Project and Getting Started:

The WordSearch project:

Standards:

Your project should be well-written, neatly-formatted, modular, and well-documented.

Grading:

OverviewScheduleResourcesAssignmentsHome

Valid HTML 4.01!Valid CSS!DePauw University, Computer Science Department, Fall 2005
Maintained by Brian Howard (bhoward@depauw.edu). Last updated