From f1faaf87e5866c88a6a150590a1baf34f1e73347 Mon Sep 17 00:00:00 2001
From: stephey <stephey>
Date: Mon, 12 Apr 2010 17:56:46 +0000
Subject: [PATCH] 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.
---
 Robust/src/Tests/mlp/stephen/Parser.java |  2 +-
 Robust/src/Tests/mlp/stephen/Test.java   | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

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()
     {
 
-- 
2.34.1