From: stephey Date: Mon, 12 Apr 2010 17:56:46 +0000 (+0000) Subject: Core of Sudoku Puzzler is ported without input error detection (no try/catch statemen... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f1faaf87e5866c88a6a150590a1baf34f1e73347;p=IRC.git Core of Sudoku Puzzler is ported without input error detection (no try/catch statements). The result writer (to file) is embedded in Test.java 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. --- diff --git a/Robust/src/Tests/mlp/stephen/Parser.java b/Robust/src/Tests/mlp/stephen/Parser.java index f9438c93..abb181d9 100644 --- a/Robust/src/Tests/mlp/stephen/Parser.java +++ b/Robust/src/Tests/mlp/stephen/Parser.java @@ -53,7 +53,7 @@ public class Parser } } - System.out.println("Parsing complete, returning result"); + System.out.println("Parsing complete."); return preBoard; } } diff --git a/Robust/src/Tests/mlp/stephen/Test.java b/Robust/src/Tests/mlp/stephen/Test.java index 04a6655c..127c8857 100755 --- a/Robust/src/Tests/mlp/stephen/Test.java +++ b/Robust/src/Tests/mlp/stephen/Test.java @@ -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() {