public static InterfaceGrille changeGrille(InterfaceGrille g) { char[] tabstr = new char[10]; char[] tabsubst = new char[10]; int indicetab = 1, j, mem = -1; char derniercar = '1'; String grilleTransformee = ""; char c; boolean trouve; String maGrille = g.toString(); tabstr[0] = maGrille.charAt(0); if (tabstr[0] == '0') tabsubst[0] = '0'; // '.' else tabsubst[0] = derniercar++; grilleTransformee += tabsubst[0]; for (int i = 1; i < 81; i++) { c = maGrille.charAt(i); trouve = false; j = 0; while (j < indicetab) { if (c == tabstr[j]) { trouve = true; mem = j; } j++; } if (trouve) grilleTransformee += tabsubst[mem]; else { tabstr[indicetab] = c; if (c == '0') tabsubst[indicetab] = '0'; // '.' else tabsubst[indicetab] = derniercar++; grilleTransformee += tabsubst[indicetab++]; } } return new Grille(grilleTransformee); }
public static InterfaceGrille tourneGrille(InterfaceGrille g) { String reverse = ""; int i = 8, j; String grille = g.toString(); for (j = 0; j < 81; j++) { reverse += grille.charAt(i); i += 9; if (i > 81) i -= 82; } return new Grille(reverse); }
public static InterfaceGrille symetrieGrille(InterfaceGrille g) { String reverse = ""; int i = 8, j, k = 0; String grille = g.toString(); for (j = 0; j < 81; j++) { reverse += grille.charAt(i + k); i--; if (i < 0) { i = 8; k += 9; } } return new Grille(reverse); }