diff --git a/src/showGrid.java b/src/showGrid.java index 78938ed..f08a388 100644 --- a/src/showGrid.java +++ b/src/showGrid.java @@ -3,28 +3,8 @@ public class showGrid { private List gridList = new ArrayList(); - private List gridList2 = new ArrayList(); - private List gridList3 = new ArrayList(); public void run() { - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - gridList3.add(new String[] { " ", " ", " ", " " }); - - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList2.add(new String[] { " ", " ", " ", " " }); - gridList.add(new String[] {"H", " ", " ", "P"}); gridList.add(new String[] {"?", "G", "N", "?"}); gridList.add(new String[] {"L", "A", "?", "S"}); @@ -34,111 +14,11 @@ gridList.add(new String[] {" ", "R", "I", "N"}); gridList.add(new String[] {" ", "I", "K", " "}); - for (int i = 0; i < gridList.size(); ++i) { - for (int z = 0; z < gridList.get(i).length; ++z) { - if (!gridList.get(i)[z].equals(" ")) { - if (z + 1 < gridList.get(i).length - && i + 1 < gridList.size()) { - if (!gridList.get(i)[z + 1].equals(" ") - && !gridList.get(i + 1)[z].equals(" ")) { - gridList2.get(i)[z] = "B"; - } - else if (!gridList.get(i)[z + 1].equals(" ")) { - gridList2.get(i)[z] = "R"; - } - else if (!gridList.get(i + 1)[z].equals(" ")) { - gridList2.get(i)[z] = "D"; - } - } else { - if (z + 1 == gridList.get(i).length - && i + 1 < gridList.size()) { - gridList2.get(i)[z] = "D"; - } - else if (z + 1 < gridList.get(i).length - && i + 1 == gridList.size()) { - gridList2.get(i)[z] = "R"; - } - else { - gridList2.get(i)[z] = "E"; - } - } - } - - System.out.print(gridList2.get(i)[z]); - } - System.out.println(); - } - - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < 1; ++i) { if (!needChecking()) break; System.out.println("Starting round " + (i + 1)); checkGrid(); } - - //List words found - /*for (int i = 0; i < gridList.size(); ++i) { - for (int z = 0; z < gridList.get(i).length; ++z) { - if (gridList2.get(i)[z].equals("B")) { - if (i <= 0 - || gridList2.get(i - 1)[z].equals(" ")) { - - String word = ""; - for (int y = i; y < gridList.size(); ++y) { - if (y + 1 < gridList.size() - && gridList.get(y)[z].equals(" ")) { - break; - } - word += gridList.get(y)[z]; - } - System.out.println("Word3: " + word); - } - if (z <= 0 - || gridList2.get(i)[z - 1].equals(" ")) { - - String word = ""; - for (int x = z; x < gridList.get(i).length; ++x) { - if (x + 1 < gridList.size() - && gridList.get(i)[x].equals(" ")) { - break; - } - word += gridList.get(i)[x]; - } - System.out.println("Word3: " + word); - } - } - if (gridList2.get(i)[z].equals("D")) { - if (i <= 0 - || gridList2.get(i - 1)[z].equals(" ")) { - - String word = ""; - for (int y = i; y < gridList.size(); ++y) { - if (y + 1 < gridList.size() - && gridList.get(y)[z].equals(" ")) { - break; - } - word += gridList.get(y)[z]; - } - System.out.println("Word: " + word); - } - } - else if(gridList2.get(i)[z].equals("R")) { - if (z <= 0 - || gridList2.get(i)[z - 1].equals(" ")) { - - String word = ""; - for (int x = z; x < gridList.get(i).length; ++x) { - if (x + 1 < gridList.size() - && gridList.get(i)[x].equals(" ")) { - break; - } - word += gridList.get(i)[x]; - } - System.out.println("Word2: " + word); - } - } - } - } - */ } private void checkGrid() { @@ -214,7 +94,7 @@ private String searchX(int i, int z) { for (int x = z; x >= 0; --x) { if (x <= 0 - || gridList2.get(i)[x - 1].equals(" ")) { + || gridList.get(i)[x - 1].equals(" ")) { String word = ""; for (int x2 = x; x2 < gridList.get(i).length; ++x2) { if (gridList.get(i)[x2].equals(" ")) { @@ -231,7 +111,7 @@ private String searchY(int i, int z) { for (int y = i; y >= 0; --y) { if (y <= 0 - || gridList2.get(y - 1)[z].equals(" ")) { + || gridList.get(y - 1)[z].equals(" ")) { String word = ""; for (int y2 = y; y2 < gridList.size(); ++y2) { if (gridList.get(y2)[z].equals(" ")) {