Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎

2018-11-07

posted Nov 7, 2018, 6:07 AM by Konstantinovich Samuel   [ updated Nov 7, 2018, 8:01 AM ]
Goal: Quiz2, Wordsearch getting started.


HW:
Here is a base set of methods to get you started! Complete them!

Make a git repo:
MKS21X-WordSearch


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

    /**Initialize the grid to the size specified 
     *and fill all of the positions with '_'
     *@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 underscores'_'*/
    private void clear(){
    }

    /**Each row is a new line, there is a space between each letter
     *@return a String with each character separated by spaces, and rows
     *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 
     * and the board is NOT modified.
     */
    public boolean addWordHorizontal(String word,int row, int col){
    }

   /**Attempts to add a given word to the specified position of the WordGrid.
     *The word is added from top to bottom, 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.
     *and the board is NOT modified.
     */
    public boolean addWordVertical(String word,int row, int col){
    }
}

using javadoc produces documentation like this:
  • Constructor Detail

    • WordSearch

      public WordSearch​(int rows,
                        int cols)
      Initialize the grid to the size specified and fill all of the positions with '_'
      Parameters:
      row - is the starting height of the WordSearch
      col - is the starting width of the WordSearch
  • Method Detail

    • toString

      public java.lang.String toString()
      Each row is a new line, letters are separated by a space
      Overrides:
      toString in class java.lang.Object
      Returns:
      a String with each character separated by spaces, and rows separated by newlines.


Comments