Ad
  • Custom User Avatar

    Most of the sample tests are incorrect.

    assertArrayEquals(new String[][]{
              {"2", "+", "3", "=", "5"},
              {"+", " ", "+", " ", "+"},
              {"4", "+", "1", "=", "5"},
              {"+", " ", "+", " ", "+"},
              {"6", "+", "2", "=", "8"} // 5 + 5 != 8, the symbols in the fourth row should = instead of +.
          }, CrossMath.solve(new String[][]{
              {"2", "+", "3", "=", "C"},
              {"+", " ", "+", " ", "+"},
              {"A", "+", "1", "=", "5"},
              {"+", " ", "+", " ", "+"},
              {"6", "+", "B", "=", "8"}
          }));
    
    assertArrayEquals(new String[][]{
              {"1", "+", "3", "=", "4"},
              {"+", " ", "-", " ", "+"},
              {"3", "-", "3", "=", "0"},
              {"=", " ", "=", " ", "="},
              {"4", "+", "0", "=", "8"} // 4 + 0 != 8.
          }, CrossMath.solve(new String[][]{
              {"1", "+", "3", "=", "4"},
              {"+", " ", "-", " ", "+"},
              {"A", "-", "3", "=", "0"},
              {"=", " ", "=", " ", "="},
              {"B", "+", "C", "=", "8"}
          }));
    
    assertArrayEquals(new String[][]{
              {"48", "/", "2", "=", "24"},
              {"/",  " ", "/",  " ", "/"},
              {"24", "/", "2", "=", "12"},
              {"=",  " ", "=",  " ", "="},
              {"12", "/", "2", "=", "6"} // 48 / 24 != 12; 2 / 2 != 2; 24 / 12 != 6.
          }, CrossMath.solve(new String[][]{
              {"48", "/", "C", "=", "24"},
              {"/",  " ", "/",  " ", "/"},
              {"24", "/", "B", "=", "12"},
              {"=",  " ", "=",  " ", "="},
              {"A", "/", "2", "=", "6"}
          }));
    
  • Custom User Avatar
  • Custom User Avatar
    src/test/java/CraftingCheckerTest.java:9: error: cannot find symbol
        private static final String STONE = CraftingChecker.STONE;
                                                           ^
      symbol:   variable STONE
      location: class CraftingChecker
    src/test/java/CraftingCheckerTest.java:10: error: cannot find symbol
        private static final String STICK = CraftingChecker.STICK;
                                                           ^
      symbol:   variable STICK
      location: class CraftingChecker
    2 errors
    

    I think it would make more sense for the tests to stand alone and not depend on static constants in the solution.