ajout ex2 tp4
This commit is contained in:
40
DEV3.1/TP04/02_Quiz/Makefile
Normal file
40
DEV3.1/TP04/02_Quiz/Makefile
Normal file
@@ -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 ###
|
Binary file not shown.
BIN
DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class
Normal file
BIN
DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Main.class
Normal file
Binary file not shown.
BIN
DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class
Normal file
BIN
DEV3.1/TP04/02_Quiz/build/fr/iutfbleau/Quiz/Question.class
Normal file
Binary file not shown.
Binary file not shown.
56
DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java
Normal file
56
DEV3.1/TP04/02_Quiz/src/AffichageQuestion.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
0
DEV3.1/TP04/02_Quiz/src/AffichageResultat.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/AffichageResultat.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/ChoixUtilisateur.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/FenetreQuiz.java
Normal file
8
DEV3.1/TP04/02_Quiz/src/Main.java
Normal file
8
DEV3.1/TP04/02_Quiz/src/Main.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
0
DEV3.1/TP04/02_Quiz/src/Navigation.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/Navigation.java
Normal file
28
DEV3.1/TP04/02_Quiz/src/Question.java
Normal file
28
DEV3.1/TP04/02_Quiz/src/Question.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
39
DEV3.1/TP04/02_Quiz/src/SourceQuestions.java
Normal file
39
DEV3.1/TP04/02_Quiz/src/SourceQuestions.java
Normal file
@@ -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);
|
||||
}
|
||||
}
|
0
DEV3.1/TP04/02_Quiz/src/ValidationChoix.java
Normal file
0
DEV3.1/TP04/02_Quiz/src/ValidationChoix.java
Normal file
Reference in New Issue
Block a user