From 33691f11fba999e2d8a20533d0bd18d4a80674f9 Mon Sep 17 00:00:00 2001 From: Simoes Lukas Date: Sat, 27 Sep 2025 17:38:27 +0200 Subject: [PATCH] ajout ex2 tp4 --- DEV3.1/TP04/02_Quiz/Makefile | 40 +++++++++++++ .../fr/iutfbleau/Quiz/AffichageQuestion.class | Bin 0 -> 1866 bytes .../build/fr/iutfbleau/Quiz/Main.class | Bin 0 -> 510 bytes .../build/fr/iutfbleau/Quiz/Question.class | Bin 0 -> 657 bytes .../fr/iutfbleau/Quiz/SourceQuestions.class | Bin 0 -> 1258 bytes .../TP04/02_Quiz/src/AffichageQuestion.java | 56 ++++++++++++++++++ .../TP04/02_Quiz/src/AffichageResultat.java | 0 DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java | 0 DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java | 0 DEV3.1/TP04/02_Quiz/src/Main.java | 8 +++ DEV3.1/TP04/02_Quiz/src/Navigation.java | 0 DEV3.1/TP04/02_Quiz/src/Question.java | 28 +++++++++ DEV3.1/TP04/02_Quiz/src/SourceQuestions.java | 39 ++++++++++++ DEV3.1/TP04/02_Quiz/src/ValidationChoix.java | 0 14 files changed, 171 insertions(+) create mode 100644 DEV3.1/TP04/02_Quiz/Makefile create mode 100644 DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/AffichageQuestion.class create mode 100644 DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class create mode 100644 DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class create mode 100644 DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/SourceQuestions.class create mode 100644 DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java create mode 100644 DEV3.1/TP04/02_Quiz/src/AffichageResultat.java create mode 100644 DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java create mode 100644 DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java create mode 100644 DEV3.1/TP04/02_Quiz/src/Main.java create mode 100644 DEV3.1/TP04/02_Quiz/src/Navigation.java create mode 100644 DEV3.1/TP04/02_Quiz/src/Question.java create mode 100644 DEV3.1/TP04/02_Quiz/src/SourceQuestions.java create mode 100644 DEV3.1/TP04/02_Quiz/src/ValidationChoix.java diff --git a/DEV3.1/TP04/02_Quiz/Makefile b/DEV3.1/TP04/02_Quiz/Makefile new file mode 100644 index 0000000..9907744 --- /dev/null +++ b/DEV3.1/TP04/02_Quiz/Makefile @@ -0,0 +1,40 @@ +### VARIABLES ### + +JC = javac +JCFLAGS = -encoding UTF-8 -implicit:none -d build -cp build -sourcepath "src" src/ + +JVM = java +JVMFLAGS = -cp build + +PACKAGE_NAME = fr.iutfbleau.Quiz. + +### REGLES ESSENTIELLES ### + +Question.class : Question.class + ${JC} ${JCFLAGS}Question.java + +SourceQuestions.class : SourceQuestions.class Question.class + ${JC} ${JCFLAGS}SourceQuestions.java + +AffichageQuestion.class : AffichageQuestion.class Question.class + ${JC} ${JCFLAGS}AffichageQuestion.java + +Main.class : Main.class AffichageQuestion.class SourceQuestions.class + ${JC} ${JCFLAGS}Main.java + + +### REGLES OPTIONNELLES ### + +run : Main.class + ${JVM} ${JVMFLAGS} ${PACKAGE_NAME}Main + +clean : + -rm -r build/fr/iutfbleau/Quiz/*.class + +mrproper : clean Main.class + +### BUTS FACTICES ### + +.PHONY : run clean mrproper + +### FIN ### \ No newline at end of file diff --git a/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/AffichageQuestion.class b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/AffichageQuestion.class new file mode 100644 index 0000000000000000000000000000000000000000..fea64dda4da318b615a934e563a928c7b4bbb155 GIT binary patch literal 1866 zcmX^0Z`VEs1_mdFTrLJC24;2!79Ivx1~x_pp{&HR#0vf5^31$+eJ{77#N1Ry1~!|_ zyv!0iMh0dL%`i>|4hBwk1}+{3ZU!Dk2IaIO{mjymw4|KW#8Umh(#$G-$F#J}QwvO`HOO>69tM5}0Y(On>8VB5AVXCc8KmLTP(z*b z^NLG~5;OBkin$n+8JIa4lo`}{7&JhBW=${3OsN2gXz?&;!$m4VBDy>bdLR)_kec$$ zl#&dPr~wayAxM-9B$|<$nVwMs5;o>xFaZg(q-Eyhurru3GVsIQ;h9&Q3bNaj!2%TR zmW&MS8lIk@kOb+p=3%g5uw`Um%LFT9WDrDn5TetXoxvVGsrV!&rRH!kI5Ie~GdS}w zxG=afGDzW$XhsI^^wbj1ypqh4(wtOA1`!QSh%GsZdFlGWB}JKe>DF8fb`0(y7kV%< zh(d!ISsoJeUOWum3_gqu%!w%}j0{>(b)ZOe&d)8#&r8iKv4$FsDk#Ljz~INj;Li}i z$RM7Zn4RjJpO>6i5}sL-0gj@?ypm#&#hy^z$X0`V8pOj8%n-uJz?Gg_;$HwtaA4({ z(U?AAX9#0t5C%m6Ja0LbmXze@aWRB4xHB@yYv9WinqiC#EYA5Usf-N#KACx`ex7F zDdu2EU}Ruq$cWO)1{+wGi~ zlM|d-l4{M!z~h;hms;eUlUQ7wTFlOn$;hCJ;U|cVs7_^P$Yx}a!>^Q)feqp>21N!A z1||ju1||k3P|*lx@iPc8FfcGOFfy<*L@+QiL^3ciE@fb6U}s=p_^!2`fl*6)D+9Y0 z%T@+nEkVW!f=qk1F$ii2qzI&JV-VG1+r}WFwVOdEayx_EHU|0K49bz)8B~3BShg~# z=`e3)(9~hy%Af-x^g&!Bo!tzkksKTx9NQVpw=!7mX0VIY-p1gtox#mdOLrTCXE;bi zYYPMKE(Tu)hV2Y)RxCOkAhSUFn3n$TK7`C^F20lgxMNBQh`K3k4aP`HE4E*V-d8tLIMKB{68RRrHeK0k`@-hJk^B Hi9r?sm5y^~ literal 0 HcmV?d00001 diff --git a/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class new file mode 100644 index 0000000000000000000000000000000000000000..0aa949d43a9126c90b24760d59eded047f173d82 GIT binary patch literal 657 zcmX^0Z`VEs1_mbv1uh0A24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3VKv?Be?(vq~KoYcfp{lL=9D*eFH)Z&uN{5(bm zj?BE0%#zZaR7M6NAB4HVB}JKe>DC~V_;?uj83Y&^*z*fOT8bGNgrl*m6yjkJW)NXy z5X{U=Nv&|o&&x{6i5}sL-;hdjWT#}eqQq0I8rs3(S>4R`Ua7j^S zUb;0qgD}iWu)83_LJW)yq97y17#T!0u4Rw^Ox~K2fj77$F*(~eu>foYJA(=% z15>moJA)b{gD@6nGBR*Moa2@WvQPxVftgpV2MS_F1_7u1{F365qQnB<)RK(+lwuAB zZAJ!8MuiFmMg?01dkzL&Mg~Skel`YuE(QYzLv{uuP_W2C*q8y@Z^BIIB*+n@dSw%VYAkr-yjLZK&+|3{!sSDDzok4N~0|NsS z*wJnbf(#4{oD3Wc+zk8-JPcwCd<=370u0IwLJS%VA`He1q6~HnA`C7J5)9r9(hPwN zvJ9~d@(gJV3JkdniVQUj@(fK3stigD3=FCatp6Fb8Q9qw*clnw8H5WuQ%D~K^4z^x{L6d=jfscWSL63ovK?_XkFqkkfFmN$2GMF-$GgvZ6 F0szv;F9HAn literal 0 HcmV?d00001 diff --git a/DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java b/DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java new file mode 100644 index 0000000..2b9c594 --- /dev/null +++ b/DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java @@ -0,0 +1,56 @@ +package fr.iutfbleau.Quiz; + +import java.awt.*; +import javax.swing.*; + + +public class AffichageQuestion extends JFrame { + + private Question questions; + private int compteur; + + public AffichageQuestion(Question questions) { + this.questions = questions; + this.compteur = 1; + + this.setSize(400, 700); + this.setLocation(100, 100); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + this.setLayout(new GridBagLayout()); + + GridBagConstraints gbc = new GridBagConstraints(); + + gbc.gridx = 1; + gbc.gridy = 0; + gbc.gridwidth = 4; + gbc.gridheight = 4; + + gbc.fill = GridBagConstraints.NONE; + + gbc.insets = new Insets(5, 5, 5, 5); + + JLabel intitule = new JLabel(questions.getIntitule()); + this.add(intitule); + + JLabel compteur = new JLabel("" + this.compteur); + + gbc.gridx = 5; + gbc.insets = new Insets(0, 0, 0, 0); + + this.add(intitule); + + gbc.gridy = 2; + gbc.gridx = 2; + gbc.gridwidth = 2; + + for (int i = 0; i != this.questions.getOptions().length; i++) { + JButton option = new JButton(this.questions.getOptions()[i]); + this.add(option); + gbc.gridy++; + gbc.insets = new Insets(0, 0, 0, 5); + } + + } + +} \ No newline at end of file diff --git a/DEV3.1/TP04/02_Quiz/src/AffichageResultat.java b/DEV3.1/TP04/02_Quiz/src/AffichageResultat.java new file mode 100644 index 0000000..e69de29 diff --git a/DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java b/DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java new file mode 100644 index 0000000..e69de29 diff --git a/DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java b/DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java new file mode 100644 index 0000000..e69de29 diff --git a/DEV3.1/TP04/02_Quiz/src/Main.java b/DEV3.1/TP04/02_Quiz/src/Main.java new file mode 100644 index 0000000..4f4fd28 --- /dev/null +++ b/DEV3.1/TP04/02_Quiz/src/Main.java @@ -0,0 +1,8 @@ +package fr.iutfbleau.Quiz; + +public class Main { + public static void main(String[] args) { + AffichageQuestion fenetre = new AffichageQuestion(SourceQuestions.genererQuestion()); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV3.1/TP04/02_Quiz/src/Navigation.java b/DEV3.1/TP04/02_Quiz/src/Navigation.java new file mode 100644 index 0000000..e69de29 diff --git a/DEV3.1/TP04/02_Quiz/src/Question.java b/DEV3.1/TP04/02_Quiz/src/Question.java new file mode 100644 index 0000000..bd69755 --- /dev/null +++ b/DEV3.1/TP04/02_Quiz/src/Question.java @@ -0,0 +1,28 @@ +package fr.iutfbleau.Quiz; + +import java.awt.*; + +public class Question { + + private String intitule; + private String[] options; + private int indexBonneReponse; + + public Question(String intitule, String[] options, int indexBonneReponse) { + this.intitule = intitule; + this.options = options; + this.indexBonneReponse = indexBonneReponse; + } + + public String getIntitule() { + return this.intitule; + } + + public String[] getOptions() { + return this.options; + } + + public int getIndexBonneReponse() { + return this.indexBonneReponse; + } +} \ No newline at end of file diff --git a/DEV3.1/TP04/02_Quiz/src/SourceQuestions.java b/DEV3.1/TP04/02_Quiz/src/SourceQuestions.java new file mode 100644 index 0000000..b3d7986 --- /dev/null +++ b/DEV3.1/TP04/02_Quiz/src/SourceQuestions.java @@ -0,0 +1,39 @@ +package fr.iutfbleau.Quiz; + +import java.util.Arrays; +import java.util.Random; + + +public class SourceQuestions { + public static Question genererQuestion() { + Random r = new Random(); + + int x = r.nextInt(11); + int y = r.nextInt(11); + + String intitule = x + " x " + y + " = ?"; + + int bonneReponse = x*y; + + int[] mauvaisesReponses = new int[4]; + + for (int i = 0; i != mauvaisesReponses.length; i++) { + mauvaisesReponses[i] = r.nextInt(101); + } + + int indexBonneReponse = r.nextInt(4); + + + String[] options = new String[4]; + + options[indexBonneReponse] = "" + bonneReponse; + + for (int i = 0; i != 4; i++) { + if (i != indexBonneReponse) { + options[i] = "" + mauvaisesReponses[i]; + } + } + + return new Question(intitule, options, indexBonneReponse); + } +} \ No newline at end of file diff --git a/DEV3.1/TP04/02_Quiz/src/ValidationChoix.java b/DEV3.1/TP04/02_Quiz/src/ValidationChoix.java new file mode 100644 index 0000000..e69de29