why this task wont verify, any help please
package com.codegym.task.task20.task2027;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/*
Word search
*/
public class Solution {
public static void main(String[] args) {
int[][] wordSearch = new int[][]{
{'f', 'd', 'e', 'r', 'l', 'k'},
{'u', 's', 'a', 'm', 'e', 'o'},
{'l', 'n', 'g', 'r', 'o', 'v'},
{'m', 'l', 'p', 'r', 'r', 'h'},
{'p', 'o', 'e', 'e', 'j', 'j'}
};
detectAllWords(wordSearch, "home", "same","hannah","ee");
/*
Expected result
home - (5, 3) - (2, 0)
same - (1, 1) - (4, 1)
*/
}
public static List<Word> detectAllWords(int[][] wordSearch, String... words){
int[][] tempWordSearch= new int[wordSearch.length][wordSearch[0].length];
ArrayList<Word> wordList = new ArrayList<>();
for (int i = 0; i < words.length; i++) {
for (int row = 0; row < wordSearch.length; row++) {
for (int column = 0; column < wordSearch[0].length; column++) {
if (( int)words[i].charAt(0) == wordSearch[row][column]) {
for (int r = 0; r < wordSearch.length; r++) {
for (int c = 0; c < wordSearch[0].length; c++) {
tempWordSearch[r][c] = wordSearch[r][c];
}
}
for (int counter8 = 0; counter8 < 8;counter8++) {
int[] values = checkWord(tempWordSearch, words[i], i, row, column);
if (values != null) {
wordList.add(new Word(words[i]));
wordList.get(wordList.size()-1).setStartPoint(values[0], values[1]);
wordList.get(wordList.size()-1).setEndPoint(values[2], values[3]);
tempWordSearch[values[3]][values[2]]=32;
}
}
}
}
}
}
for (int i = 0;i<wordList.size();i++){
System.out.println(wordList.get(i));
}
return wordList;
}
public static int[] checkWord(int[][] wordSearch,String word,int i, int row, int column){
String checkWord = (char)wordSearch[row][column]+"";
int [] returnArray = new int[4];
int startx = column;
int starty = row;
int letter = 1;
int lock =0;
int counter = 0;
int reverseWordLock = 0;
while (true) {
counter++;
StringBuilder sb = new StringBuilder(word);
String reveerse = sb.reverse().toString();
if (word.equals(reveerse)) {
reverseWordLock = 1;
}
if (checkWord.equals(word)) {
returnArray[0] = startx;
returnArray[1] = starty;
returnArray[2] = column;
returnArray[3] = row;
return returnArray;
}
//*********************************************
try {
if ((lock == 0 || lock == 1) & (int) word.charAt(letter) == wordSearch[row][column + 1]) {
lock = 1;
column = column+1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 2) & (int) word.charAt(letter) == wordSearch[row][column - 1] & reverseWordLock ==0) {
lock = 2;
column = column-1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 3) & (int) word.charAt(letter) == wordSearch[row + 1][column]) {
lock = 3;
row = row+1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 4) & (int) word.charAt(letter) == wordSearch[row - 1][column] & reverseWordLock ==0) {
lock = 4;
row = row-1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 5) & (int) word.charAt(letter) == wordSearch[row + 1][column + 1]) {
lock = 5;
row = row+1;
column = column+1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 6) & (int) word.charAt(letter) == wordSearch[row + 1][column - 1] & reverseWordLock ==0) {
lock = 6;
row = row+1;
column = column-1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 7) & (int) word.charAt(letter) == wordSearch[row - 1][column + 1]) {
lock = 7;
row = row-1;
column = column+1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
try {
if ((lock == 0 || lock == 8) & (int) word.charAt(letter) == wordSearch[row - 1][column - 1] & reverseWordLock ==0) {
lock = 8;
row = row-1;
column = column-1;
checkWord = checkWord+(char)wordSearch[row][column];
letter++;
}
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException e) {
}
//*********************************************
if (counter > word.length()){
return null;
}
//*********************************************
}
}
public static class Word {
private String text;
private int startX;
private int startY;
private int endX;
private int endY;
public Word(String text) {
this.text = text;
}
public void setStartPoint(int i, int j) {
startX = i;
startY = j;
}
public void setEndPoint(int i, int j) {
endX = i;
endY = j;
}
@Override
public String toString() {
return String.format("%s - (%d, %d) - (%d, %d)", text, startX, startY, endX, endY);
}
}
}