Core of Sudoku Puzzler is ported without input error detection (no try/catch statemen...
authorstephey <stephey>
Mon, 12 Apr 2010 17:56:46 +0000 (17:56 +0000)
committerstephey <stephey>
Mon, 12 Apr 2010 17:56:46 +0000 (17:56 +0000)
Lessons Learned
1)  There are fewer implicit type casts with our compiler.
2)  Error Handling
2a) Functions that could throw an error but does not return anything can return a boolean to check for errors.
2b) Functions that do return something can return either a null (if returning an object) or an invalid value to check for errors.

Robust/src/Tests/mlp/stephen/Parser.java
Robust/src/Tests/mlp/stephen/Test.java

index f9438c93f833671ae8091968670977b2edc8d746..abb181d9558c03730e70b390fef7f0a0226a7d53 100644 (file)
@@ -53,7 +53,7 @@ public class Parser
                        }
                }
                
-               System.out.println("Parsing complete, returning result");
+               System.out.println("Parsing complete.");
                return preBoard;
        }
 }
index 04a6655c77dcc9156f9d98510fa6c9bff3074fbb..127c8857fbcec3be2e8623dca1f3b2a30a1e9b6c 100755 (executable)
@@ -19,11 +19,23 @@ public class Test
                {
                        Board b = new Board(data);
                        Board solved = Solver.go(b);
+                       System.out.println("Here's the best I could do:");
                        System.out.println(solved);
+                       writeResults(b.toString(), solved.toString());
                }
                
        }       
 
+    public void writeResults(String org, String solved)
+    {
+       FileOutputStream out = new FileOutputStream("out.txt");
+       out.write("Input puzzle:\n".getBytes());
+       out.write(org.getBytes());
+       out.write("\nProcessed Puzzle:\n".getBytes());
+       out.write(solved.getBytes());
+       out.close();
+    }
+
     public void doSomeWorkSolvingStaticPuzzle()
     {