From 2d715a4b044ed43f89286478c821121aa1466f5d Mon Sep 17 00:00:00 2001 From: EmmanuelTiamzon Date: Mon, 13 Oct 2025 16:55:26 +0200 Subject: [PATCH] update --- .../ex2Quiz/src/Vue/AffichageQuestion.java | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/DEV.3.1/TP/TP4/ex2Quiz/src/Vue/AffichageQuestion.java b/DEV.3.1/TP/TP4/ex2Quiz/src/Vue/AffichageQuestion.java index d628336..66d6a51 100644 --- a/DEV.3.1/TP/TP4/ex2Quiz/src/Vue/AffichageQuestion.java +++ b/DEV.3.1/TP/TP4/ex2Quiz/src/Vue/AffichageQuestion.java @@ -1,17 +1,76 @@ +package Vue; + +import javax.swing.*; +import Modele.Question; +import Modele.Questionnaire; +import Modele.ChoixUtilisateur; +import java.awt.*; + /** * Classe pour l'affichage des questions */ -public class AffichageQuestion { +public class AffichageQuestion extends JPanel { /** * Mode solution activé ou non (false si mode questionnaire, true si mode solution) */ private boolean modeSolution; + private JRadioButton[] boutonsChoix; + /** * Constructeur de la classe AffichageQuestion */ public AffichageQuestion() { - this.modeSolution = false; + this.modeSolution = false; } -} \ No newline at end of file +} + +/* +Copylot crap +package Vue; + +import javax.swing.*; +import java.awt.*; +import Modele.Question; +import Modele.ChoixUtilisateur; + +public class AffichageQuestion extends JPanel { + private boolean modeSolution; + private ButtonGroup group; + private JRadioButton[] boutons; + private JLabel labelQuestion; + + public AffichageQuestion(Question question, int indexQuestion, ChoixUtilisateur choixUtilisateur, boolean modeSolution) { + this.modeSolution = modeSolution; + setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + + labelQuestion = new JLabel(question.makeNewQuestion()); + gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; + add(labelQuestion, gbc); + + String[] propositions = question.getPropositions(); + boutons = new JRadioButton[propositions.length]; + group = new ButtonGroup(); + + for (int i = 0; i < propositions.length; i++) { + boutons[i] = new JRadioButton(propositions[i]); + boutons[i].setEnabled(!modeSolution); + if (choixUtilisateur.getChoix(indexQuestion) == i) { + boutons[i].setSelected(true); + } + if (modeSolution) { + if (i == question.getCorrectIndex()) { + boutons[i].setForeground(Color.GREEN); + } else if (choixUtilisateur.getChoix(indexQuestion) == i) { + boutons[i].setForeground(Color.RED); + } + } + group.add(boutons[i]); + gbc.gridy = i + 1; gbc.gridwidth = 2; + add(boutons[i], gbc); + } + } +} + */ \ No newline at end of file