Case grisée quand grille importé dans SudokuGame + sa Javadoc
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# List of Java source files
|
||||
SRCS := Cell.java GenerateGrid.java Grid.java Sudoku.java SudokuButtonListener.java SudokuSolver.java SudokuUI.java SudokuCreator.java
|
||||
SRCS := Cell.java GenerateGrid.java Grid.java Sudoku.java SudokuButtonListener.java SudokuSolver.java SudokuUI.java SudokuCreator.java SudokuGame.java
|
||||
|
||||
# Directory to store compiled class files
|
||||
BUILD_DIR := build
|
||||
|
||||
+28
-1
@@ -6,25 +6,41 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* La classe SudokuGame étend la classe SudokuUI et représente une application de jeu de Sudoku avec des fonctionnalités supplémentaires telles que le chargement de grilles et la résolution automatique.
|
||||
*/
|
||||
public class SudokuGame extends SudokuUI {
|
||||
|
||||
/**
|
||||
* Constructeur de la classe SudokuGame.
|
||||
* @param sudoku La grille de Sudoku à utiliser pour le jeu.
|
||||
*/
|
||||
public SudokuGame(Sudoku sudoku) {
|
||||
super(sudoku);
|
||||
createAdditionalButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode pour obtenir le texte du titre de l'interface utilisateur.
|
||||
* @return Le texte du titre.
|
||||
*/
|
||||
@Override
|
||||
protected String getTitleText() {
|
||||
return "Sudoku Game";
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode pour créer les boutons de chargement et de résolution et redimensionner la fenêtre.
|
||||
*/
|
||||
protected void createAdditionalButtons() {
|
||||
createLoadButton();
|
||||
createSolveButton();
|
||||
pack(); // Redimensionner la fenêtre pour s'adapter aux nouveaux boutons
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Méthode pour créer le bouton de résolution.
|
||||
*/
|
||||
private void createSolveButton() {
|
||||
JButton solveButton = new JButton("Résoudre");
|
||||
solveButton.addActionListener(new ActionListener() {
|
||||
@@ -51,6 +67,9 @@ public class SudokuGame extends SudokuUI {
|
||||
add(buttonPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode pour créer le bouton de chargement.
|
||||
*/
|
||||
private void createLoadButton() {
|
||||
JButton loadButton = new JButton("Charger");
|
||||
loadButton.addActionListener(new ActionListener() {
|
||||
@@ -73,16 +92,24 @@ public class SudokuGame extends SudokuUI {
|
||||
add(buttonPanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode pour mettre à jour les valeurs des boutons de la grille après un chargement ou une résolution.
|
||||
*/
|
||||
private void updateGrid() {
|
||||
Grid grid = sudoku.getGrid();
|
||||
for (int row = 0; row < 9; row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
int value = grid.getCell(row, col).getValue();
|
||||
buttons[row][col].setText(value == 0 ? "" : String.valueOf(value));
|
||||
buttons[row][col].setEnabled(value == 0); // Désactive les boutons pour les cellules déjà remplies
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode principale pour démarrer le jeu de Sudoku.
|
||||
* @param args Les arguments de la ligne de commande (non utilisés).
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Sudoku sudoku = new Sudoku();
|
||||
new SudokuGame(sudoku);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user