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 0000000..fea64dd Binary files /dev/null and b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/AffichageQuestion.class differ diff --git a/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class new file mode 100644 index 0000000..f89d45d Binary files /dev/null and b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class differ 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 0000000..0aa949d Binary files /dev/null and b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class differ diff --git a/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/SourceQuestions.class b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/SourceQuestions.class new file mode 100644 index 0000000..a7b395c Binary files /dev/null and b/DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/SourceQuestions.class differ 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