diff --git a/S1.02/Jeu/classes/Labyrinthe.class b/S1.02/Jeu/classes/Labyrinthe.class index cdab49c79008e67e476e0067adfcfdae0d49fd6e..873129f18278620eff82c2a791d3ccd468c241b0 100644 Binary files a/S1.02/Jeu/classes/Labyrinthe.class and b/S1.02/Jeu/classes/Labyrinthe.class differ diff --git a/S1.02/Jeu/src/Labyrinthe.java b/S1.02/Jeu/src/Labyrinthe.java index 37bd1e6215ee950e841f105b416788608a6a20ff..a49d078f9803f3cdaa7d1ee8bc2fa6d7f8be3368 100644 --- a/S1.02/Jeu/src/Labyrinthe.java +++ b/S1.02/Jeu/src/Labyrinthe.java @@ -364,7 +364,7 @@ class Labyrinthe extends Program{ } } - void afficheQuestion(Question q, boolean reponseLibre){ + void afficheQuestion(Question q, boolean reponseLibre){ //Affiche les questions println("################################################################################" + '\n' + "####@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@####" + '\n' + "####@ @####"); @@ -381,7 +381,7 @@ class Labyrinthe extends Program{ } - Question[] listeQuestion(String cheminFichier){ + Question[] listeQuestion(String cheminFichier){ //Charge le csv des question et renvoie un tableau de question qui possède une Question par case String[][] lQuestion = load(cheminFichier); Question[] res = new Question[length(lQuestion, 1)-1]; for(int i = 0; i < length(res); i ++){ @@ -398,6 +398,15 @@ class Labyrinthe extends Program{ assertEquals(test2.question, tabTest[length(tabTest)-1].question); } + Question questionRandom(Question[] liste, int nbUtilisees){ + int choix = (int) (random()*length(liste)-nbUtilisees); + Question res = liste[choix]; + Question temp = liste[nbUtilisees]; + liste[choix] = temp; + liste[nbUtilisees] = res; + return res; + } + boolean questionCorrect(Question q){ //Vérifie si on donne la bonne réponse String res = readString(); return equals(toLowerCase(res), toLowerCase(q.reponse)); @@ -437,16 +446,17 @@ class Labyrinthe extends Program{ } void _algorithm(){ Salle[][] lab = genererLab(5); //genere le Layrinthe - String[][] lQuestion = load("ressources/ListeQuestion.csv"); + String[][] questionTemp = load("ressources/ListeQuestion.csv"); print("Voulez vous ajouter des question ? oui (o), non (autre) : "); boolean ques = equals(toLowerCase(readString()), "o"); if(ques){ print("Combien voulez vous en ajouter ? : "); int nbAjout = readInt(); - ajoutQuestion(lQuestion, nbAjout); - lQuestion = load("ressources/ListeQuestion.csv"); - afficheStringTab(lQuestion); + ajoutQuestion(questionTemp, nbAjout); + questionTemp = load("ressources/ListeQuestion.csv"); + afficheStringTab(questionTemp); } + Question[] lQuestion = listeQuestion("ressources/ListeQuestion.csv"); for(int i = 0; i<length(lab,1);i++){ for(int j=0;j<length(lab,2);j++){