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);
|
graphics2D.drawLine(postXCoordinate, marginPixels, postXCoordinate + beamLength, marginPixels);
|
||||||
|
|
||||||
// Renfort diagonal
|
// Renfort diagonal
|
||||||
graphics2D.drawLine(postXCoordinate, marginPixels + height / 10,
|
graphics2D.drawLine(postXCoordinate, marginPixels + height / 10, postXCoordinate + width / 12, marginPixels);
|
||||||
postXCoordinate + width / 12, marginPixels);
|
|
||||||
|
|
||||||
// Corde
|
// Corde
|
||||||
int ropeXCoordinate = postXCoordinate + beamLength;
|
int ropeXCoordinate = postXCoordinate + beamLength;
|
||||||
@@ -60,8 +59,7 @@ public class Dessin extends JPanel {
|
|||||||
int headRadiusPixels = Math.min(width, height) / 16;
|
int headRadiusPixels = Math.min(width, height) / 16;
|
||||||
int headCenterX = ropeXCoordinate;
|
int headCenterX = ropeXCoordinate;
|
||||||
int headCenterY = ropeBottomYCoordinate + headRadiusPixels;
|
int headCenterY = ropeBottomYCoordinate + headRadiusPixels;
|
||||||
graphics2D.drawOval(headCenterX - headRadiusPixels, headCenterY - headRadiusPixels,
|
graphics2D.drawOval(headCenterX - headRadiusPixels, headCenterY - headRadiusPixels, headRadiusPixels * 2, headRadiusPixels * 2);
|
||||||
headRadiusPixels * 2, headRadiusPixels * 2);
|
|
||||||
|
|
||||||
// Corps
|
// Corps
|
||||||
int bodyTopYCoordinate = headCenterY + headRadiusPixels;
|
int bodyTopYCoordinate = headCenterY + headRadiusPixels;
|
||||||
@@ -71,17 +69,13 @@ public class Dessin extends JPanel {
|
|||||||
// Bras
|
// Bras
|
||||||
int armSpanPixels = width / 10;
|
int armSpanPixels = width / 10;
|
||||||
int shouldersYCoordinate = bodyTopYCoordinate + height / 24;
|
int shouldersYCoordinate = bodyTopYCoordinate + height / 24;
|
||||||
graphics2D.drawLine(headCenterX, shouldersYCoordinate,
|
graphics2D.drawLine(headCenterX, shouldersYCoordinate, headCenterX - armSpanPixels, shouldersYCoordinate + height / 20);
|
||||||
headCenterX - armSpanPixels, shouldersYCoordinate + height / 20);
|
graphics2D.drawLine(headCenterX, shouldersYCoordinate, headCenterX + armSpanPixels, shouldersYCoordinate + height / 20);
|
||||||
graphics2D.drawLine(headCenterX, shouldersYCoordinate,
|
|
||||||
headCenterX + armSpanPixels, shouldersYCoordinate + height / 20);
|
|
||||||
|
|
||||||
// Jambes
|
// Jambes
|
||||||
int legSpanPixels = width / 12;
|
int legSpanPixels = width / 12;
|
||||||
graphics2D.drawLine(headCenterX, bodyBottomYCoordinate,
|
graphics2D.drawLine(headCenterX, bodyBottomYCoordinate, headCenterX - legSpanPixels, bodyBottomYCoordinate + height / 8);
|
||||||
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();
|
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.
@@ -8,16 +8,16 @@ import java.util.function.Consumer;
|
|||||||
* - Action sur Entrée ou clic bouton
|
* - Action sur Entrée ou clic bouton
|
||||||
* - Notification du handler externe (fourni au constructeur)
|
* - Notification du handler externe (fourni au constructeur)
|
||||||
* Aucune logique de jeu ici.
|
* Aucune logique de jeu ici.
|
||||||
* @version 1.2
|
* @version 1.3
|
||||||
* author Adrien
|
* author Adrien
|
||||||
* Date : 08-10-2025
|
* Date : 08-10-2025
|
||||||
* Licence :
|
|
||||||
*/
|
*/
|
||||||
public class Event implements ActionListener {
|
public class Event implements ActionListener {
|
||||||
|
|
||||||
private final Fenetre window;
|
private final Fenetre window;
|
||||||
private final Consumer<Character> onLetterSubmitted;
|
private final Consumer<Character> onLetterSubmitted;
|
||||||
|
|
||||||
|
/** Constructeur : conserve les références et branche les événements. */
|
||||||
public Event(Fenetre window, Consumer<Character> onLetterSubmitted) {
|
public Event(Fenetre window, Consumer<Character> onLetterSubmitted) {
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.onLetterSubmitted = onLetterSubmitted;
|
this.onLetterSubmitted = onLetterSubmitted;
|
||||||
@@ -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
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
submitLetter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Récupère, valide et transmet la lettre au handler externe. */
|
|
||||||
private void submitLetter() {
|
|
||||||
JTextField letterInput = window.getLetterInput();
|
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]")) {
|
if (inputText.length() != 1 || !inputText.matches("[A-Z]")) {
|
||||||
JOptionPane.showMessageDialog(window.getWindow(), "Veuillez entrer une seule lettre (A-Z).");
|
JOptionPane.showMessageDialog(window.getWindow(), "Veuillez entrer une seule lettre (A-Z).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notification du handler externe, sinon placeholder
|
||||||
if (onLetterSubmitted != null) {
|
if (onLetterSubmitted != null) {
|
||||||
onLetterSubmitted.accept(inputText.charAt(0));
|
onLetterSubmitted.accept(inputText.charAt(0));
|
||||||
} else {
|
} 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