Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. public static int curRow = 10;
  2. public static int curCol = 10;
  3.  
  4. public static boolean stop = false;
  5.  
  6. public static String[][] wordSearch = {{"H","M","G","R","R","A","U","S","G","U"},
  7. {"U","S","M","J","E","A","F","R","K","W"},
  8. {"X","M","C","L","P","J","D","N","M","S"},
  9. {"I","A","F","O","O","S","M","X","A","F"},
  10. {"R","R","J","O","L","O","O","P","T","N"},
  11. {"T","G","B","C","E","H","X","M","H","W"},
  12. {"A","O","G","H","V","Y","R","B","Y","M"},
  13. {"M","R","A","J","E","L","M","A","X","L"},
  14. {"R","P","W","A","D","T","A","C","Y","B"},
  15. {"H","N","S","A","I","T","E","R","Y","X"}};//Default
  16.  
  17.  
  18. private static void searchDiagonalRightToCenter(String word) {//Center to bottom Right. Diagnol Works, debug to go along column is needed
  19.  
  20. int rowOn = 0;
  21. int colOn = 0;
  22.  
  23. int resetableCol = curCol;
  24. resetableCol--;//Just resets everything then starts again.
  25.  
  26. int decreaser = curCol;//What to decrease by everytime it runs 10,9,8,7 all the way to 1
  27. int resetableDec = decreaser;
  28. resetableDec--;
  29.  
  30. char c;
  31.  
  32. String toFind = word.toUpperCase();
  33.  
  34. String developingInverse = "";
  35.  
  36. int integer = 0;
  37.  
  38. for(int row = 0; row < curRow; row++)//Matrices Row
  39. {
  40. for(int i = resetableCol; i <= resetableDec; i--)
  41. {
  42.  
  43. String developingWord = "";
  44.  
  45. integer = i;
  46.  
  47. for(int j = integer; j <= resetableDec; j++,integer++)
  48. {
  49. System.out.println(j +" and " + i + " and " + resetableDec);
  50. c = wordSearch[integer][j].charAt(0);//Sets to whatever letter it is on
  51. char uC = Character.toUpperCase(c);
  52. developingWord = developingWord + "" +uC;
  53.  
  54. System.out.println("On Row: " + row + " Started From: " + integer + " Now On: " + j);
  55. System.out.println("Processing Letter: " + wordSearch[j][integer] + " Adding Letter To: " + developingWord);
  56.  
  57. if(toFind.equals(developingWord))
  58. {
  59. rowOn = row; colOn = i;
  60. rowOn++; colOn++;
  61. System.out.println("\nLocated Word: " + toFind + ". Word Was Diagonal Located Within The Row.");
  62. System.out.println("Row " + (rowOn) + " and Starting At Column " + (colOn));
  63. stop = true;
  64. return;
  65. }
  66.  
  67. StringBuffer sb = new StringBuffer(developingWord);
  68. sb.reverse();
  69. developingInverse = sb.toString();
  70.  
  71. if(toFind.equals(developingInverse)) {
  72. rowOn = row; colOn = i;
  73. rowOn++; colOn++;
  74. System.out.println("\nLocated Word: " + toFind + ". Word Was Diagonal Located Reversed Within The Row.");
  75. System.out.println("Row " + (rowOn) + " and Starting At Column " + (colOn));
  76. stop = true;
  77. return;
  78. }
  79. }
  80.  
  81. }
  82. }
  83. System.out.println("\nNo Matching Word Was Found, Moving To Diagonal Center To Left.");
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement