Answer 1. The code won't compile in its current form, cause your catch clause should be written as follows:
catch (illegalPuzzle e)
{
System.out.println("Illegal puzzle.");
System.exit(1);
}
Answer 2. Just throw Exception
(the base class of all Exceptions) in your try, and remove illegalPuzzle
class altogether. Here's how:
public class SudokuSolver
{
public static void main(String[] args)
{
try
{
// other statements
throw new Exception();
}
catch (Exception e)
{
System.out.println("Illegal puzzle.");
System.exit(1);
}
}
}
Answer 3. Answer 2 answers this part as well.