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); } }