verification grille avant exportation
This commit is contained in:
parent
d6404ad9c8
commit
0fccdac81e
BIN
Sudoku/grille$1.class
Normal file
BIN
Sudoku/grille$1.class
Normal file
Binary file not shown.
BIN
Sudoku/grille$2.class
Normal file
BIN
Sudoku/grille$2.class
Normal file
Binary file not shown.
BIN
Sudoku/grille.class
Normal file
BIN
Sudoku/grille.class
Normal file
Binary file not shown.
@ -7,6 +7,7 @@ import javax.swing.border.Border;
|
|||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
|
|
||||||
public class grille extends JComponent{
|
public class grille extends JComponent{
|
||||||
|
private static JLabel etat_exportation = new JLabel();
|
||||||
|
|
||||||
/*tableau de valeurs de la grille de sudoku*/
|
/*tableau de valeurs de la grille de sudoku*/
|
||||||
public static int[][] grid_values = null;
|
public static int[][] grid_values = null;
|
||||||
@ -99,11 +100,15 @@ public class grille extends JComponent{
|
|||||||
JButton exporter = null;
|
JButton exporter = null;
|
||||||
JPanel bouton_grille = new JPanel();
|
JPanel bouton_grille = new JPanel();
|
||||||
|
|
||||||
|
|
||||||
if(editable){
|
if(editable){
|
||||||
|
|
||||||
|
bouton_grille.add(etat_exportation);
|
||||||
exporter = new JButton("exporter");
|
exporter = new JButton("exporter");
|
||||||
bouton_grille.add(exporter);
|
bouton_grille.add(exporter);
|
||||||
place_grille.add(bouton_grille);
|
place_grille.add(bouton_grille);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
verifier = new JButton("verifier");
|
verifier = new JButton("verifier");
|
||||||
bouton_grille.add(verifier);
|
bouton_grille.add(verifier);
|
||||||
place_grille.add(bouton_grille);
|
place_grille.add(bouton_grille);
|
||||||
@ -128,7 +133,23 @@ public class grille extends JComponent{
|
|||||||
if (exporter != null) { /* Vérification pour s'assurer que exporter a été initialisé */
|
if (exporter != null) { /* Vérification pour s'assurer que exporter a été initialisé */
|
||||||
exporter.addActionListener(new ActionListener() {
|
exporter.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent exporter) {
|
public void actionPerformed(ActionEvent exporter) {
|
||||||
ExporterGrille(ConvertirGrilleActuelle(place_grille));
|
for (int i=0; i < 9; i++){
|
||||||
|
for (int j=0; j < 9; j++){
|
||||||
|
System.out.print(GrilleActuelle(place_grille)[i][j]);
|
||||||
|
}
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(resolveurGrille.resoudreSudoku(GrilleActuelle(place_grille)))){
|
||||||
|
etat_exportation.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
etat_exportation.setText("Sudoku Impossible.");
|
||||||
|
etat_exportation.setForeground(Color.RED);
|
||||||
|
System.out.println(1);
|
||||||
|
} else {
|
||||||
|
ExporterGrille(GrilleActuelle(place_grille));
|
||||||
|
etat_exportation.setText("");
|
||||||
|
System.out.println(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -206,7 +227,7 @@ public class grille extends JComponent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[][] ConvertirGrilleActuelle(JPanel place_grille){
|
public static int[][] GrilleActuelle(JPanel place_grille){
|
||||||
int[][] grilleActuelle = new int[9][9];
|
int[][] grilleActuelle = new int[9][9];
|
||||||
|
|
||||||
for (Component comp : place_grille.getComponents()) {
|
for (Component comp : place_grille.getComponents()) {
|
||||||
|
BIN
Sudoku/mainProgramme1.class
Normal file
BIN
Sudoku/mainProgramme1.class
Normal file
Binary file not shown.
BIN
Sudoku/mainProgramme2.class
Normal file
BIN
Sudoku/mainProgramme2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$1.class
Normal file
BIN
Sudoku/menuProgramme1$1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$2.class
Normal file
BIN
Sudoku/menuProgramme1$2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$3.class
Normal file
BIN
Sudoku/menuProgramme1$3.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$4.class
Normal file
BIN
Sudoku/menuProgramme1$4.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1.class
Normal file
BIN
Sudoku/menuProgramme1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$1.class
Normal file
BIN
Sudoku/menuProgramme2$1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$2.class
Normal file
BIN
Sudoku/menuProgramme2$2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$3.class
Normal file
BIN
Sudoku/menuProgramme2$3.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$4.class
Normal file
BIN
Sudoku/menuProgramme2$4.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$5.class
Normal file
BIN
Sudoku/menuProgramme2$5.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2.class
Normal file
BIN
Sudoku/menuProgramme2.class
Normal file
Binary file not shown.
BIN
Sudoku/resolveurGrille.class
Normal file
BIN
Sudoku/resolveurGrille.class
Normal file
Binary file not shown.
@ -17,8 +17,9 @@ public class resolveurGrille {
|
|||||||
return solution;
|
return solution;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean resoudreSudoku(int[][] grille) {
|
public static boolean resoudreSudoku(int[][] grille) {
|
||||||
/*parcourage la grille*/
|
/*parcourage la grille*/
|
||||||
|
stop = false;
|
||||||
for (int row = 0; row < 9; row++) {
|
for (int row = 0; row < 9; row++) {
|
||||||
for (int col = 0; col < 9; col++) {
|
for (int col = 0; col < 9; col++) {
|
||||||
if (grille[row][col] == 0) {
|
if (grille[row][col] == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user