diff --git a/Sudoku/.gitignore b/Sudoku/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/Sudoku/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/Sudoku/Sudoku/.project b/Sudoku/Sudoku/.project new file mode 100644 index 0000000..b273577 --- /dev/null +++ b/Sudoku/Sudoku/.project @@ -0,0 +1,17 @@ + + + Sudoku + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Sudoku/grille$1.class b/Sudoku/grille$1.class new file mode 100644 index 0000000..6eac38d Binary files /dev/null and b/Sudoku/grille$1.class differ diff --git a/Sudoku/grille.class b/Sudoku/grille.class new file mode 100644 index 0000000..6983917 Binary files /dev/null and b/Sudoku/grille.class differ diff --git a/Sudoku/grille.java b/Sudoku/grille.java index bd45803..d98e9a3 100644 --- a/Sudoku/grille.java +++ b/Sudoku/grille.java @@ -3,7 +3,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; -import javax.swing.border.LineBorder; +import javax.swing.border.Border; import javax.swing.text.*; public class grille extends JComponent{ @@ -30,20 +30,29 @@ public class grille extends JComponent{ if(editable){ JTextField[][] case_editable = null; case_editable = new JTextField[9][9]; - for (int i = 0; i < 9; i++) { - for (int j = 0; j < 9; j++) { - if (grille[i][j] == 0){ - case_editable[i][j] = new JTextField("", 1); + for (int ligne = 0; ligne < 9; ligne++) { + for (int col = 0; col < 9; col++) { + if (grille[ligne][col] == 0){ + case_editable[ligne][col] = new JTextField("", 1); }else{ - case_editable[i][j] = new JTextField(String.valueOf(grille[i][j]), 1); + case_editable[ligne][col] = new JTextField(String.valueOf(grille[ligne][col]), 1); } - case_editable[i][j].setBorder(new LineBorder(Color.BLACK, 5)); - case_editable[i][j].setFont(new Font("Arial", Font.PLAIN, 30)); - case_editable[i][j].setHorizontalAlignment(JTextField.CENTER); - place_grille.add(case_editable[i][j]); - } + case_editable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30)); + case_editable[ligne][col].setHorizontalAlignment(JTextField.CENTER); + if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){ + case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK)); + } else if((ligne % 3 == 0) && (ligne != 0)){ + case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK)); + } else if ((col % 3 == 0) && (col != 0)){ + case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK)); + } else { + case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK)); + } + place_grille.add(case_editable[ligne][col]); + } } - }else{ + + } else { /*affichage de la grille*/ JTextField[][] case_modifiable = null; @@ -51,20 +60,36 @@ public class grille extends JComponent{ case_depart = new JLabel[9][9]; case_modifiable = new JTextField[9][9]; - for (int i = 0; i < 9; i++) { - for (int j = 0; j < 9; j++) { - if ((grid_values[i][j]) == 0) { - case_modifiable[i][j] = new JTextField("", 1); - case_modifiable[i][j].setBorder(new LineBorder(Color.BLACK, 5)); - case_modifiable[i][j].setFont(new Font("Arial", Font.PLAIN, 30)); - case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER); - place_grille.add(case_modifiable[i][j]); + for (int ligne = 0; ligne < 9; ligne++) { + for (int col = 0; col < 9; col++) { + if ((grid_values[ligne][col]) == 0) { + case_modifiable[ligne][col] = new JTextField("", 1); + case_modifiable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30)); + case_modifiable[ligne][col].setHorizontalAlignment(JTextField.CENTER); + if ((ligne % 3 == 0) && (ligne != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK)); + } else if ((col % 3 == 0) && (col != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK)); + } else if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK)); + }else { + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK)); + } + place_grille.add(case_modifiable[ligne][col]); } else { - case_depart[i][j] = new JLabel(String.valueOf(grid_values[i][j])); - case_depart[i][j].setBorder(new LineBorder(Color.BLACK, 5)); - case_depart[i][j].setFont(new Font("Arial", Font.PLAIN, 30)); - case_depart[i][j].setHorizontalAlignment(JTextField.CENTER); - place_grille.add(case_depart[i][j]); + case_depart[ligne][col] = new JLabel(String.valueOf(grid_values[ligne][col])); + case_depart[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30)); + case_depart[ligne][col].setHorizontalAlignment(JTextField.CENTER); + if ((ligne % 3 == 0) && (ligne != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK)); + } else if ((col % 3 == 0) && (col != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK)); + } else if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){ + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK)); + } else { + case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK)); + } + place_grille.add(case_depart[ligne][col]); } } } diff --git a/Sudoku/mainProgramme1.class b/Sudoku/mainProgramme1.class new file mode 100644 index 0000000..c5b6748 Binary files /dev/null and b/Sudoku/mainProgramme1.class differ diff --git a/Sudoku/mainProgramme2.class b/Sudoku/mainProgramme2.class new file mode 100644 index 0000000..4cd2638 Binary files /dev/null and b/Sudoku/mainProgramme2.class differ diff --git a/Sudoku/menuProgramme1$1.class b/Sudoku/menuProgramme1$1.class new file mode 100644 index 0000000..c563e1e Binary files /dev/null and b/Sudoku/menuProgramme1$1.class differ diff --git a/Sudoku/menuProgramme1$2.class b/Sudoku/menuProgramme1$2.class new file mode 100644 index 0000000..c1c25e9 Binary files /dev/null and b/Sudoku/menuProgramme1$2.class differ diff --git a/Sudoku/menuProgramme1$3.class b/Sudoku/menuProgramme1$3.class new file mode 100644 index 0000000..06cf3dc Binary files /dev/null and b/Sudoku/menuProgramme1$3.class differ diff --git a/Sudoku/menuProgramme1$4.class b/Sudoku/menuProgramme1$4.class new file mode 100644 index 0000000..6248b3f Binary files /dev/null and b/Sudoku/menuProgramme1$4.class differ diff --git a/Sudoku/menuProgramme1.class b/Sudoku/menuProgramme1.class new file mode 100644 index 0000000..41e714d Binary files /dev/null and b/Sudoku/menuProgramme1.class differ diff --git a/Sudoku/menuProgramme2$1.class b/Sudoku/menuProgramme2$1.class new file mode 100644 index 0000000..62d088d Binary files /dev/null and b/Sudoku/menuProgramme2$1.class differ diff --git a/Sudoku/menuProgramme2$2.class b/Sudoku/menuProgramme2$2.class new file mode 100644 index 0000000..1aee62c Binary files /dev/null and b/Sudoku/menuProgramme2$2.class differ diff --git a/Sudoku/menuProgramme2$3.class b/Sudoku/menuProgramme2$3.class new file mode 100644 index 0000000..23581ab Binary files /dev/null and b/Sudoku/menuProgramme2$3.class differ diff --git a/Sudoku/menuProgramme2$4.class b/Sudoku/menuProgramme2$4.class new file mode 100644 index 0000000..fad8aa5 Binary files /dev/null and b/Sudoku/menuProgramme2$4.class differ diff --git a/Sudoku/menuProgramme2$5.class b/Sudoku/menuProgramme2$5.class new file mode 100644 index 0000000..3ea1c4e Binary files /dev/null and b/Sudoku/menuProgramme2$5.class differ diff --git a/Sudoku/menuProgramme2.class b/Sudoku/menuProgramme2.class new file mode 100644 index 0000000..73f1302 Binary files /dev/null and b/Sudoku/menuProgramme2.class differ diff --git a/Sudoku/resolveurGrille.class b/Sudoku/resolveurGrille.class new file mode 100644 index 0000000..e0b145a Binary files /dev/null and b/Sudoku/resolveurGrille.class differ