public void dumpGrid ( ) { StringBuilder dumpGridSb = new StringBuilder ( ) ; Formatter fmt = new Formatter ( dumpGridSb ) ; fmt . format ( " " ) ; for ( int iCol = 0 ; iCol < 9 ; iCol ++ ) { fmt . format ( "Col: %d " , iCol ) ; } fmt . format ( "\n" ) ; for ( int iRow = 0 ; iRow < 9 ; iRow ++ ) { fmt . format ( "Row " + iRow + ": " ) ; for ( int iCol = 0 ; iCol < 9 ; iCol ++ ) { if ( cells [ iRow ] [ iCol ] . getValue ( ) != null ) { fmt . format ( " --- %d --- " , cells [ iRow ] [ iCol ] . getValue ( ) ) ; } else { StringBuilder sb = new StringBuilder ( ) ; Set < Integer > perms = cells [ iRow ] [ iCol ] . getFree ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( perms . contains ( i ) ) { sb . append ( i ) ; } else { sb . append ( ' ' ) ; } } fmt . format ( " %-10s" , sb . toString ( ) ) ; } } fmt . format ( "\n" ) ; } fmt . close ( ) ; System . out . println ( dumpGridSb ) ; }
Nice printout of the grid .