Wordsearch method 2
<p>I'm looking for more help with my wordsearch program if possible. It is part of a homework assignment. This might seem a little long winded and I'll probably get flamed for this noobieness so I apologise in advance >&lt;</p>

<p>The method needs to insert a string horizontally into a 2d array (letterGrid) at randomly generated row and column positions.</p>

<p>Within a loop that loops 10 times or until the method's argument has been entered into letterGrid.The method 1st sends two randomPosition() messages to the receiver to get values for targetRow and targetCol.</p>

<p>Then it sends isHorizontalSpaceFree(targetRow,targetCol,word) to check for space. If there isn't space then back to top of loop and try new random positions - if there is space then iterate over word and assign each character to the appropriate component in letterGrid and return true.</p>

<p>If after 10 attempts suitable starting positions can't be found then return false.</p>

<p>Here is my code so far...</p>

<pre><code>{
  int targetRow = this.randomPosition(NUMBER_ROWS);
  int targetCol = this.randomPosition(WordSearchMaker.NUMBER_COLS - word.length() + 1);
  boolean result = true;
  for (int i = 0; i &lt; word.length(); i++)
  {
  if (this.isHorizontalSpaceFree(targetRow, targetCol, word))
     {
        letterGrid[targetRow][targetCol] = word.charAt(i);
     }
  }
  return result;
}
</code></pre>

<p>My problems are with the loops and how to insert each character of the word. Any pointers are very much appreciated folks ;)</p>

<p>Thanks in advance.</p>
