forked from menault/TD3_DEV51_Qualite_Algo
		
	Event commentaire
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								src/Dessin.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Dessin.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -47,8 +47,7 @@ public class Dessin extends JPanel { | ||||
|         graphics2D.drawLine(postXCoordinate, marginPixels, postXCoordinate + beamLength, marginPixels); | ||||
|  | ||||
|         // Renfort diagonal | ||||
|         graphics2D.drawLine(postXCoordinate, marginPixels + height / 10, | ||||
|                             postXCoordinate + width / 12, marginPixels); | ||||
|         graphics2D.drawLine(postXCoordinate, marginPixels + height / 10, postXCoordinate + width / 12, marginPixels); | ||||
|  | ||||
|         // Corde | ||||
|         int ropeXCoordinate = postXCoordinate + beamLength; | ||||
| @@ -60,8 +59,7 @@ public class Dessin extends JPanel { | ||||
|         int headRadiusPixels = Math.min(width, height) / 16; | ||||
|         int headCenterX = ropeXCoordinate; | ||||
|         int headCenterY = ropeBottomYCoordinate + headRadiusPixels; | ||||
|         graphics2D.drawOval(headCenterX - headRadiusPixels, headCenterY - headRadiusPixels, | ||||
|                             headRadiusPixels * 2, headRadiusPixels * 2); | ||||
|         graphics2D.drawOval(headCenterX - headRadiusPixels, headCenterY - headRadiusPixels, headRadiusPixels * 2, headRadiusPixels * 2); | ||||
|  | ||||
|         // Corps | ||||
|         int bodyTopYCoordinate = headCenterY + headRadiusPixels; | ||||
| @@ -71,17 +69,13 @@ public class Dessin extends JPanel { | ||||
|         // Bras | ||||
|         int armSpanPixels = width / 10; | ||||
|         int shouldersYCoordinate = bodyTopYCoordinate + height / 24; | ||||
|         graphics2D.drawLine(headCenterX, shouldersYCoordinate, | ||||
|                             headCenterX - armSpanPixels, shouldersYCoordinate + height / 20); | ||||
|         graphics2D.drawLine(headCenterX, shouldersYCoordinate, | ||||
|                             headCenterX + armSpanPixels, shouldersYCoordinate + height / 20); | ||||
|         graphics2D.drawLine(headCenterX, shouldersYCoordinate, headCenterX - armSpanPixels, shouldersYCoordinate + height / 20); | ||||
|         graphics2D.drawLine(headCenterX, shouldersYCoordinate, headCenterX + armSpanPixels, shouldersYCoordinate + height / 20); | ||||
|  | ||||
|         // Jambes | ||||
|         int legSpanPixels = width / 12; | ||||
|         graphics2D.drawLine(headCenterX, bodyBottomYCoordinate, | ||||
|                             headCenterX - legSpanPixels, bodyBottomYCoordinate + height / 8); | ||||
|         graphics2D.drawLine(headCenterX, bodyBottomYCoordinate, | ||||
|                             headCenterX + legSpanPixels, bodyBottomYCoordinate + height / 8); | ||||
|         graphics2D.drawLine(headCenterX, bodyBottomYCoordinate, headCenterX - legSpanPixels, bodyBottomYCoordinate + height / 8); | ||||
|         graphics2D.drawLine(headCenterX, bodyBottomYCoordinate, headCenterX + legSpanPixels, bodyBottomYCoordinate + height / 8); | ||||
|  | ||||
|         graphics2D.dispose(); | ||||
|     } | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								src/Event$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Event$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								src/Event.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Event.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -3,28 +3,28 @@ import java.awt.event.*; | ||||
| import java.util.function.Consumer; | ||||
|  | ||||
| /** | ||||
| * La classe <code>Event</code> regroupe et branche tous les listeners liés à Fenetre. | ||||
| * - Validation de la saisie (1 lettre A-Z, majuscule) | ||||
| * - Action sur Entrée ou clic bouton | ||||
| * - Notification du handler externe (fourni au constructeur) | ||||
| * Aucune logique de jeu ici. | ||||
| * @version 1.2 | ||||
| * author Adrien | ||||
| * Date : 08-10-2025 | ||||
| * Licence : | ||||
| */ | ||||
|  * La classe <code>Event</code> regroupe et branche tous les listeners liés à Fenetre. | ||||
|  * - Validation de la saisie (1 lettre A-Z, majuscule) | ||||
|  * - Action sur Entrée ou clic bouton | ||||
|  * - Notification du handler externe (fourni au constructeur) | ||||
|  * Aucune logique de jeu ici. | ||||
|  * @version 1.3 | ||||
|  * author Adrien | ||||
|  * Date : 08-10-2025 | ||||
|  */ | ||||
| public class Event implements ActionListener { | ||||
|  | ||||
|     private final Fenetre window; | ||||
|     private final Consumer<Character> onLetterSubmitted; | ||||
|  | ||||
|     /** Constructeur : conserve les références et branche les événements. */ | ||||
|     public Event(Fenetre window, Consumer<Character> onLetterSubmitted) { | ||||
|         this.window = window; | ||||
|         this.onLetterSubmitted = onLetterSubmitted; | ||||
|         wireEvents(); | ||||
|     } | ||||
|  | ||||
|     /** Branche les listeners sur les composants de Fenetre. */ | ||||
|     /** Branche les listeners sur les composants de Fenetre.*/ | ||||
|     private void wireEvents() { | ||||
|         JTextField letterInput = window.getLetterInput(); | ||||
|         JButton sendButton = window.getSendButton(); | ||||
| @@ -47,27 +47,26 @@ public class Event implements ActionListener { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     /** Réagit à Entrée ou au clic bouton : soumet la lettre. */ | ||||
|     /** Réagit à Entrée ou au clic bouton : récupère, valide et transmet la lettre. */ | ||||
|     @Override | ||||
|     public void actionPerformed(ActionEvent actionEvent) { | ||||
|         submitLetter(); | ||||
|     } | ||||
|  | ||||
|     /** Récupère, valide et transmet la lettre au handler externe. */ | ||||
|     private void submitLetter() { | ||||
|         JTextField letterInput = window.getLetterInput(); | ||||
|         String inputText = letterInput.getText().trim().toUpperCase(); | ||||
|         letterInput.setText(""); | ||||
|  | ||||
|         String inputText = letterInput.getText().trim().toUpperCase(); | ||||
|         letterInput.setText(""); // reset du champ après tentative | ||||
|  | ||||
|         // Validation : exactement une lettre A–Z | ||||
|         if (inputText.length() != 1 || !inputText.matches("[A-Z]")) { | ||||
|             JOptionPane.showMessageDialog(window.getWindow(), "Veuillez entrer une seule lettre (A-Z)."); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Notification du handler externe, sinon placeholder | ||||
|         if (onLetterSubmitted != null) { | ||||
|             onLetterSubmitted.accept(inputText.charAt(0)); | ||||
|         } else { | ||||
|             JOptionPane.showMessageDialog(window.getWindow(), "Lettre soumise (placeholder) : " + inputText); | ||||
|             JOptionPane.showMessageDialog(window.getWindow(), | ||||
|                     "Lettre soumise (placeholder) : " + inputText); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								src/Fenetre.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Fenetre.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								src/Partie.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Partie.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								src/Pendu.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/Pendu.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user