announcements‎ > ‎

2015-11-23 hwWordSearch

posted Nov 23, 2015, 9:12 AM by Samuel Konstantinovich   [ updated Nov 24, 2015, 5:02 AM ]
Word search design today. 

Goal: Word Search basics.
-Design a data structure to hold the words.
-Decide on how the overall program would work.
-Decide on how to start writing this program.
-Implement the first method, and a way to test it.


public class WordSearch{
    private char[][]data;

    /**Initialize the grid to the size specified and fill all of the positions
     *with spaces.
     *@param row is the starting height of the WordSearch
     *@param col is the starting width of the WordSearch
    public WordSearch(int rows,int cols){

    /**Set all values in the WordSearch to spaces ' '*/
    private void clear(){

    /**The proper formatting for a WordGrid is created in the toString.
     *@return a String with each character separated by spaces, and each row
     *separated by newlines.
    public String toString(){

    /**Attempts to add a given word to the specified position of the WordGrid.
     *The word is added from left to right, must fit on the WordGrid, and must
     *have a corresponding letter to match any letters that it overlaps.
     *@param word is any text to be added to the word grid.
     *@param row is the vertical locaiton of where you want the word to start.
     *@param col is the horizontal location of where you want the word to start.
     *@return true when the word is added successfully. When the word doesn't fit,
     *or there are overlapping letters that do not match, then false is returned.
    public boolean addWordHorizontal(String word,int row, int col){

    //vertical + diagonal should be implemented as well.