1. //finds the first value in a 4x4 grid or XxX grid for that matter 2. 3. public int FindFirst(String wordToCheck, int StringPos){ 4. 5. 6. System.out.println("wordToCheck's first letter : " + wordToCheck.substring(0, 1)); 7. int LocOfFirstLetter = 23; 8. 9. for (int x = 0; x < Board.length; x++){ 10. // System.out.println("grid @ pos " + x + " is: String: " + Grid[(x/4)][(x%4)] + " row: " + x/4 + " col: " + x%4); 11. String LetterToCheck = wordToCheck.charAt(StringPos)+""; 12. System.out.println("Checking Letter : " + LetterToCheck); 13. if (LetterToCheck.equalsIgnoreCase(Grid[(x/4)][(x%4)]) == true){ 14. System.out.println("First char isOnBoard at location " + Grid[(x/Grid.length)][(x%Grid.length)] + " at r/c : " + x/4 + " " + x%4 ); 15. LocOfFirstLetter = x; 16. SelectedSquare[x]=true; 17. FindNext(wordToCheck, StringPos+1, x, (x/Grid.length),(x%Grid.length) ); 18. } 19. } 20. return LocOfFirstLetter; 21. } 22. // suppose to find the next value of the word 23. public int FindNext(String wordToCheck, int StringPos, int StartLoc, int row, int col){ 24. String LetterToCheck = wordToCheck.charAt(StringPos)+""; 25. System.out.println("Selected squre should be true: " + SelectedSquare[StartLoc]); 26. System.out.println("Next Letter is: " + LetterToCheck); 27. System.out.println("First letter at pos: " + StringPos + " row: " + row + " col : " + col); // is there a way to do this w/o 8 if statements, recursively? 28. /*positions to test 29. * 1 row,col-1 left 30. * 2 row-1,col-1 left & up 31. * 3 row-1,col up 32. * 4 row-1,col+1 up & right 33. * 5 row,col+1 right 34. * 6 row+1,col+1 right & down 35. * 7 row+1,col down 36. * 8 row+1,col-1 down & left 37. */ 38. if(row<0 || row > 4 || col <0 || col > 4 ){ 39. System.out.println("not on board"); 40. } 41. 42. 43. return 0; 44. } 45. 46. }