forked from menault/TD3_DEV51_Qualite_Algo
		
	reparation
This commit is contained in:
		| @@ -1,155 +1,132 @@ | |||||||
| package front; | package back; | ||||||
|  |  | ||||||
| import back.*; | import java.util.ArrayList; | ||||||
|  | import java.util.HashSet; | ||||||
| import javax.swing.*; | import java.util.List; | ||||||
| import java.awt.*; | import java.util.Set; | ||||||
| import java.awt.event.ActionEvent; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Interface graphique du jeu du pendu. |  * Logique principale du jeu du pendu (back). | ||||||
|  * (Toutes les méthodes ≤ 50 lignes) |  * Ajoute un score et un chronomètre. | ||||||
|  |  * | ||||||
|  |  * Règles de score (simples) : | ||||||
|  |  *  - Lettre correcte  : +10 points | ||||||
|  |  *  - Lettre incorrecte:  -5 points (le score ne descend pas sous 0) | ||||||
|  |  *  - Bonus victoire   : + (restant * 10) + bonus temps | ||||||
|  |  *      * bonus temps = max(0, 60 - secondes) * 2   (jusqu'à 120 pts si < 60s) | ||||||
|  |  *  - Défaite          : pas de bonus | ||||||
|  |  * | ||||||
|  |  * Chronomètre : | ||||||
|  |  *  - Démarre à la création de la partie | ||||||
|  |  *  - S'arrête définitivement à la fin (victoire/défaite) | ||||||
|  */ |  */ | ||||||
| public class GameUI { | public class Game { | ||||||
|     private JFrame frame; |     private final String word; | ||||||
|     private JLabel imgLabel, wordLabel, triedLabel, scoreLabel, timeLabel; |     private final Set<Character> correct = new HashSet<>(); | ||||||
|     private JTextField input; |     private final Set<Character> all = new HashSet<>(); | ||||||
|     private JButton tryBtn, newGameBtn; |     private final int maxErrors; | ||||||
|     private Game game; |     private int errors; | ||||||
|     private String currentWord; |  | ||||||
|     private Timer timer; |  | ||||||
|  |  | ||||||
|     /** Lance la fenêtre et démarre une partie */ |     // --- Score & chrono --- | ||||||
|     public void show() { |     private int score = 0; | ||||||
|         setupWindow(); |     private long startNano;       // début de partie (System.nanoTime) | ||||||
|         setupLayout(); |     private long endNano = -1L;   // fin (sinon -1 = en cours) | ||||||
|         setupActions(); |  | ||||||
|         startNewGame(); |     public Game(String word, int maxErrors) { | ||||||
|         frame.setVisible(true); |         this.word = word.toLowerCase(); | ||||||
|  |         this.maxErrors = maxErrors; | ||||||
|  |         this.startNano = System.nanoTime(); // démarre le chrono à la création | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Crée la fenêtre principale */ |     /** Tente une lettre et renvoie le résultat + ajuste le score */ | ||||||
|     private void setupWindow() { |     public Result play(char letter) { | ||||||
|         frame = new JFrame("Jeu du Pendu"); |         char c = Character.toLowerCase(letter); | ||||||
|         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |         if (all.contains(c)) return Result.ALREADY; | ||||||
|         frame.setSize(560, 560); |  | ||||||
|         frame.setLocationRelativeTo(null); |  | ||||||
|         frame.setLayout(new BorderLayout(12, 12)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Construit les composants et le layout */ |         all.add(c); | ||||||
|     private void setupLayout() { |         if (word.indexOf(c) >= 0) { | ||||||
|         imgLabel = new JLabel("", SwingConstants.CENTER); |             correct.add(c); | ||||||
|         frame.add(imgLabel, BorderLayout.CENTER); |             addScore(10); | ||||||
|  |             // Si la lettre trouvée fait gagner immédiatement, on finalise ici | ||||||
|         wordLabel = new JLabel("Mot : "); |             if (isWin()) end(true); | ||||||
|         triedLabel = new JLabel("Lettres essayées : "); |             return Result.HIT; | ||||||
|         scoreLabel = new JLabel("Score : 0"); |         } else { | ||||||
|         timeLabel = new JLabel("Temps : 0s"); |             addScore(-5); | ||||||
|  |             if (isLose()) end(false); | ||||||
|         JPanel top = new JPanel(new GridLayout(2, 1)); |             return Result.MISS; | ||||||
|         top.add(buildTopLine(wordLabel, scoreLabel)); |  | ||||||
|         top.add(buildTopLine(triedLabel, timeLabel)); |  | ||||||
|         frame.add(top, BorderLayout.NORTH); |  | ||||||
|  |  | ||||||
|         JPanel bottom = new JPanel(new BorderLayout(8, 8)); |  | ||||||
|         JPanel inputPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |  | ||||||
|         input = new JTextField(5); |  | ||||||
|         tryBtn = new JButton("Essayer"); |  | ||||||
|         newGameBtn = new JButton("Nouvelle partie"); |  | ||||||
|         inputPanel.add(new JLabel("Lettre :")); |  | ||||||
|         inputPanel.add(input); |  | ||||||
|         inputPanel.add(tryBtn); |  | ||||||
|         bottom.add(inputPanel, BorderLayout.WEST); |  | ||||||
|         bottom.add(newGameBtn, BorderLayout.EAST); |  | ||||||
|         frame.add(bottom, BorderLayout.SOUTH); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Crée une ligne du haut avec 2 labels */ |  | ||||||
|     private JPanel buildTopLine(JLabel left, JLabel right) { |  | ||||||
|         JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |  | ||||||
|         panel.add(left); |  | ||||||
|         panel.add(Box.createHorizontalStrut(24)); |  | ||||||
|         panel.add(right); |  | ||||||
|         return panel; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Ajoute les actions et le timer */ |  | ||||||
|     private void setupActions() { |  | ||||||
|         tryBtn.addActionListener(this::onTry); |  | ||||||
|         input.addActionListener(this::onTry); |  | ||||||
|         newGameBtn.addActionListener(e -> startNewGame()); |  | ||||||
|         timer = new Timer(1000, e -> refreshStatsOnly()); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Démarre une nouvelle partie */ |  | ||||||
|     private void startNewGame() { |  | ||||||
|         currentWord = Words.random(); |  | ||||||
|         game = new Game(currentWord, 7); |  | ||||||
|         input.setText(""); |  | ||||||
|         input.requestFocusInWindow(); |  | ||||||
|         if (!timer.isRunning()) timer.start(); |  | ||||||
|         refreshUI(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Gère le clic ou l'appui sur Entrée */ |  | ||||||
|     private void onTry(ActionEvent e) { |  | ||||||
|         String text = input.getText(); |  | ||||||
|         if (!Check.isLetter(text)) { |  | ||||||
|             showMsg("Tape une seule lettre (A-Z)."); |  | ||||||
|             input.requestFocusInWindow(); |  | ||||||
|             input.selectAll(); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         Result res = game.play(Character.toLowerCase(text.charAt(0))); |  | ||||||
|         handleResult(res); |  | ||||||
|         input.setText(""); |  | ||||||
|         refreshUI(); |  | ||||||
|         checkEnd(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Réagit selon le résultat d'une tentative */ |  | ||||||
|     private void handleResult(Result res) { |  | ||||||
|         switch (res) { |  | ||||||
|             case ALREADY: |  | ||||||
|                 showMsg("Lettre déjà utilisée."); |  | ||||||
|                 break; |  | ||||||
|             case HIT: |  | ||||||
|             case MISS: |  | ||||||
|                 break; // rien, juste refresh |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Vérifie si la partie est finie */ |     /** Retourne le mot masqué avec les lettres trouvées */ | ||||||
|     private void checkEnd() { |     public String maskedWord() { | ||||||
|         if (game.isWin() || game.isLose()) { |         StringBuilder sb = new StringBuilder(); | ||||||
|             timer.stop(); |         for (int i = 0; i < word.length(); i++) { | ||||||
|             game.end(game.isWin()); |             char c = word.charAt(i); | ||||||
|             String msg = (game.isWin() ? "Bravo !" : "Perdu !") |             if (!Character.isLetter(c)) sb.append(c); | ||||||
|                     + " Le mot était : " + currentWord |             else if (correct.contains(c)) sb.append(c); | ||||||
|                     + "\nScore final : " + game.getScore() |             else sb.append('_'); | ||||||
|                     + "\nTemps : " + game.getElapsedSeconds() + "s"; |             if (i < word.length() - 1) sb.append(' '); | ||||||
|             showMsg(msg); |         } | ||||||
|  |         return sb.toString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Vérifie si le joueur a gagné */ | ||||||
|  |     public boolean isWin() { | ||||||
|  |         for (int i = 0; i < word.length(); i++) { | ||||||
|  |             char c = word.charAt(i); | ||||||
|  |             if (Character.isLetter(c) && !correct.contains(c)) return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Vérifie si le joueur a perdu */ | ||||||
|  |     public boolean isLose() { | ||||||
|  |         return errors >= maxErrors; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Nombre d'erreurs actuelles */ | ||||||
|  |     public int getErrors() { return errors; } | ||||||
|  |  | ||||||
|  |     /** Liste les lettres déjà essayées */ | ||||||
|  |     public List<String> triedLetters() { | ||||||
|  |         List<Character> sorted = new ArrayList<>(all); | ||||||
|  |         sorted.sort(Character::compareTo); | ||||||
|  |         List<String> out = new ArrayList<>(); | ||||||
|  |         for (Character ch : sorted) out.add(String.valueOf(ch)); | ||||||
|  |         return out; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // ---------- Score & Chrono ---------- | ||||||
|  |  | ||||||
|  |     /** Retourne le score courant */ | ||||||
|  |     public int getScore() { return score; } | ||||||
|  |  | ||||||
|  |     /** Secondes écoulées depuis le début (si finie, temps figé) */ | ||||||
|  |     public long getElapsedSeconds() { | ||||||
|  |         long end = (endNano > 0L) ? endNano : System.nanoTime(); | ||||||
|  |         long deltaNs = end - startNano; | ||||||
|  |         if (deltaNs < 0) deltaNs = 0; | ||||||
|  |         return deltaNs / 1_000_000_000L; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Termine la partie (victoire/défaite) et applique le bonus si gagné */ | ||||||
|  |     public void end(boolean win) { | ||||||
|  |         if (endNano > 0L) return; // déjà terminé | ||||||
|  |         endNano = System.nanoTime(); | ||||||
|  |         if (win) { | ||||||
|  |             int remaining = Math.max(0, maxErrors - errors); | ||||||
|  |             int timeBonus = (int) Math.max(0, 60 - getElapsedSeconds()) * 2; | ||||||
|  |             addScore(remaining * 10 + timeBonus); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Met à jour tout l'affichage */ |     // --- utilitaires privés --- | ||||||
|     private void refreshUI() { |     private void addScore(int delta) { | ||||||
|         imgLabel.setIcon(Gallows.icon(game.getErrors())); |         if (delta < 0) { | ||||||
|         wordLabel.setText("Mot : " + game.maskedWord()); |             // lettre ratée => +1 erreur | ||||||
|         triedLabel.setText("Lettres essayées : " + String.join(", ", game.triedLetters())); |             errors++; | ||||||
|         refreshStatsOnly(); |         } | ||||||
|         frame.repaint(); |         score += delta; | ||||||
|     } |         if (score < 0) score = 0; | ||||||
|  |  | ||||||
|     /** Met à jour uniquement score + chrono */ |  | ||||||
|     private void refreshStatsOnly() { |  | ||||||
|         scoreLabel.setText("Score : " + game.getScore()); |  | ||||||
|         timeLabel.setText("Temps : " + game.getElapsedSeconds() + "s"); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** Affiche une boîte de message */ |  | ||||||
|     private void showMsg(String msg) { |  | ||||||
|         JOptionPane.showMessageDialog(frame, msg); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,76 +1,85 @@ | |||||||
| package front; | package front; | ||||||
|  |  | ||||||
| import back.*; | import back.*; | ||||||
|  |  | ||||||
| import javax.swing.*; | import javax.swing.*; | ||||||
| import java.awt.*; | import java.awt.*; | ||||||
| import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Interface graphique (Swing) du jeu du pendu. |  * Interface graphique du jeu du pendu. | ||||||
|  * - Affiche une image différente à chaque erreur. |  * (Toutes les méthodes ≤ 50 lignes) | ||||||
|  * - Champ de saisie pour entrer une lettre. |  | ||||||
|  * - Texte pour le mot masqué et les lettres essayées. |  | ||||||
|  */ |  */ | ||||||
| public class GameUI { | public class GameUI { | ||||||
|     private JFrame frame; |     private JFrame frame; | ||||||
|     private JLabel imgLabel; |     private JLabel imgLabel, wordLabel, triedLabel, scoreLabel, timeLabel; | ||||||
|     private JLabel wordLabel; |  | ||||||
|     private JLabel triedLabel; |  | ||||||
|     private JTextField input; |     private JTextField input; | ||||||
|     private JButton tryBtn; |     private JButton tryBtn, newGameBtn; | ||||||
|     private JButton newGameBtn; |  | ||||||
|  |  | ||||||
|     private Game game; |     private Game game; | ||||||
|     private String currentWord; |     private String currentWord; | ||||||
|  |     private Timer timer; | ||||||
|  |  | ||||||
|     /** Affiche la fenêtre principale */ |     /** Lance la fenêtre et démarre une partie */ | ||||||
|     public void show() { |     public void show() { | ||||||
|         setupUI(); |         setupWindow(); | ||||||
|  |         setupLayout(); | ||||||
|  |         setupActions(); | ||||||
|         startNewGame(); |         startNewGame(); | ||||||
|         frame.setVisible(true); |         frame.setVisible(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Initialise les composants Swing */ |     /** Crée la fenêtre principale */ | ||||||
|     private void setupUI() { |     private void setupWindow() { | ||||||
|         frame = new JFrame("Jeu du Pendu"); |         frame = new JFrame("Jeu du Pendu"); | ||||||
|         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||||||
|         frame.setSize(520, 520); |         frame.setSize(560, 560); | ||||||
|         frame.setLocationRelativeTo(null); |         frame.setLocationRelativeTo(null); | ||||||
|         frame.setLayout(new BorderLayout(12, 12)); |         frame.setLayout(new BorderLayout(12, 12)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // Image du pendu |     /** Construit les composants et le layout */ | ||||||
|  |     private void setupLayout() { | ||||||
|         imgLabel = new JLabel("", SwingConstants.CENTER); |         imgLabel = new JLabel("", SwingConstants.CENTER); | ||||||
|         frame.add(imgLabel, BorderLayout.CENTER); |         frame.add(imgLabel, BorderLayout.CENTER); | ||||||
|  |  | ||||||
|         // Panneau bas: saisie + actions |         wordLabel = new JLabel("Mot : "); | ||||||
|  |         triedLabel = new JLabel("Lettres essayées : "); | ||||||
|  |         scoreLabel = new JLabel("Score : 0"); | ||||||
|  |         timeLabel = new JLabel("Temps : 0s"); | ||||||
|  |  | ||||||
|  |         JPanel top = new JPanel(new GridLayout(2, 1)); | ||||||
|  |         top.add(buildTopLine(wordLabel, scoreLabel)); | ||||||
|  |         top.add(buildTopLine(triedLabel, timeLabel)); | ||||||
|  |         frame.add(top, BorderLayout.NORTH); | ||||||
|  |  | ||||||
|         JPanel bottom = new JPanel(new BorderLayout(8, 8)); |         JPanel bottom = new JPanel(new BorderLayout(8, 8)); | ||||||
|         JPanel inputPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |         JPanel inputPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); | ||||||
|         input = new JTextField(5); |         input = new JTextField(5); | ||||||
|         tryBtn = new JButton("Essayer"); |         tryBtn = new JButton("Essayer"); | ||||||
|  |         newGameBtn = new JButton("Nouvelle partie"); | ||||||
|         inputPanel.add(new JLabel("Lettre :")); |         inputPanel.add(new JLabel("Lettre :")); | ||||||
|         inputPanel.add(input); |         inputPanel.add(input); | ||||||
|         inputPanel.add(tryBtn); |         inputPanel.add(tryBtn); | ||||||
|  |  | ||||||
|         newGameBtn = new JButton("Nouvelle partie"); |  | ||||||
|         bottom.add(inputPanel, BorderLayout.WEST); |         bottom.add(inputPanel, BorderLayout.WEST); | ||||||
|         bottom.add(newGameBtn, BorderLayout.EAST); |         bottom.add(newGameBtn, BorderLayout.EAST); | ||||||
|         frame.add(bottom, BorderLayout.SOUTH); |         frame.add(bottom, BorderLayout.SOUTH); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // Panneau haut: mot + lettres essayées |     /** Crée une ligne du haut avec 2 labels */ | ||||||
|         JPanel top = new JPanel(); |     private JPanel buildTopLine(JLabel left, JLabel right) { | ||||||
|         top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS)); |         JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); | ||||||
|         wordLabel = new JLabel("Mot : "); |         panel.add(left); | ||||||
|         triedLabel = new JLabel("Lettres essayées : "); |         panel.add(Box.createHorizontalStrut(24)); | ||||||
|         wordLabel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |         panel.add(right); | ||||||
|         triedLabel.setBorder(BorderFactory.createEmptyBorder(0, 8, 8, 8)); |         return panel; | ||||||
|         top.add(wordLabel); |     } | ||||||
|         top.add(triedLabel); |  | ||||||
|         frame.add(top, BorderLayout.NORTH); |  | ||||||
|  |  | ||||||
|         // Actions |     /** Ajoute les actions et le timer */ | ||||||
|  |     private void setupActions() { | ||||||
|         tryBtn.addActionListener(this::onTry); |         tryBtn.addActionListener(this::onTry); | ||||||
|         input.addActionListener(this::onTry); |         input.addActionListener(this::onTry); | ||||||
|         newGameBtn.addActionListener(e -> startNewGame()); |         newGameBtn.addActionListener(e -> startNewGame()); | ||||||
|  |         timer = new Timer(1000, e -> refreshStatsOnly()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Démarre une nouvelle partie */ |     /** Démarre une nouvelle partie */ | ||||||
| @@ -79,47 +88,68 @@ public class GameUI { | |||||||
|         game = new Game(currentWord, 7); |         game = new Game(currentWord, 7); | ||||||
|         input.setText(""); |         input.setText(""); | ||||||
|         input.requestFocusInWindow(); |         input.requestFocusInWindow(); | ||||||
|  |         if (!timer.isRunning()) timer.start(); | ||||||
|         refreshUI(); |         refreshUI(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Gère le clic sur "Essayer" ou Entrée dans le champ */ |     /** Gère le clic ou l'appui sur Entrée */ | ||||||
|     private void onTry(ActionEvent e) { |     private void onTry(ActionEvent e) { | ||||||
|         String text = input.getText(); |         String text = input.getText(); | ||||||
|         if (!Check.isLetter(text)) { |         if (!Check.isLetter(text)) { | ||||||
|             JOptionPane.showMessageDialog(frame, "Tape une seule lettre (A-Z)."); |             showMsg("Tape une seule lettre (A-Z)."); | ||||||
|             input.requestFocusInWindow(); |             input.requestFocusInWindow(); | ||||||
|             input.selectAll(); |             input.selectAll(); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         char c = Character.toLowerCase(text.charAt(0)); |         Result res = game.play(Character.toLowerCase(text.charAt(0))); | ||||||
|         Result res = game.play(c); |         handleResult(res); | ||||||
|  |  | ||||||
|         switch (res) { |  | ||||||
|             case ALREADY: JOptionPane.showMessageDialog(frame, "Lettre déjà utilisée."); |  | ||||||
|             break; |  | ||||||
|             case HIT: |  | ||||||
|             break; |  | ||||||
|             case MISS: |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         input.setText(""); |         input.setText(""); | ||||||
|         refreshUI(); |         refreshUI(); | ||||||
|  |         checkEnd(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         if (game.isWin()) { |     /** Réagit selon le résultat d'une tentative */ | ||||||
|             refreshUI(); |     private void handleResult(Result res) { | ||||||
|             JOptionPane.showMessageDialog(frame, "Bravo ! Le mot était : " + currentWord); |         switch (res) { | ||||||
|         } else if (game.isLose()) { |             case ALREADY: | ||||||
|             refreshUI(); |                 showMsg("Lettre déjà utilisée."); | ||||||
|             JOptionPane.showMessageDialog(frame, "Perdu ! Le mot était : " + currentWord); |                 break; | ||||||
|  |             case HIT: | ||||||
|  |             case MISS: | ||||||
|  |                 break; // rien, juste refresh | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Met à jour l'image et les textes selon l'état courant */ |     /** Vérifie si la partie est finie */ | ||||||
|  |     private void checkEnd() { | ||||||
|  |         if (game.isWin() || game.isLose()) { | ||||||
|  |             timer.stop(); | ||||||
|  |             game.end(game.isWin()); | ||||||
|  |             String msg = (game.isWin() ? "Bravo !" : "Perdu !") | ||||||
|  |                     + " Le mot était : " + currentWord | ||||||
|  |                     + "\nScore final : " + game.getScore() | ||||||
|  |                     + "\nTemps : " + game.getElapsedSeconds() + "s"; | ||||||
|  |             showMsg(msg); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Met à jour tout l'affichage */ | ||||||
|     private void refreshUI() { |     private void refreshUI() { | ||||||
|         imgLabel.setIcon(Gallows.icon(game.getErrors())); |         imgLabel.setIcon(Gallows.icon(game.getErrors())); | ||||||
|         wordLabel.setText("Mot : " + game.maskedWord()); |         wordLabel.setText("Mot : " + game.maskedWord()); | ||||||
|         triedLabel.setText("Lettres essayées : " + String.join(", ", game.triedLetters())); |         triedLabel.setText("Lettres essayées : " + String.join(", ", game.triedLetters())); | ||||||
|  |         refreshStatsOnly(); | ||||||
|         frame.repaint(); |         frame.repaint(); | ||||||
|     } |     } | ||||||
| } |  | ||||||
|  |     /** Met à jour uniquement score + chrono */ | ||||||
|  |     private void refreshStatsOnly() { | ||||||
|  |         scoreLabel.setText("Score : " + game.getScore()); | ||||||
|  |         timeLabel.setText("Temps : " + game.getElapsedSeconds() + "s"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Affiche une boîte de message */ | ||||||
|  |     private void showMsg(String msg) { | ||||||
|  |         JOptionPane.showMessageDialog(frame, msg); | ||||||
|  |     } | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								TD3 - DEV5.1.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								TD3 - DEV5.1.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user