Fin de fini + comm

This commit is contained in:
2025-10-08 14:44:57 +02:00
parent df3186be0e
commit 2760d87804
5 changed files with 22770 additions and 14 deletions

22743
francais.txt Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -91,12 +91,14 @@ public class main {
System.out.println(hangman[mistakes]); System.out.println(hangman[mistakes]);
} }
//Element toujours présent
public void showGame(){ public void showGame(){
System.out.println("lettre fausse : " + this.curentLetter.incorrectLetters); System.out.println("lettre fausse : " + this.curentLetter.incorrectLetters);
displayHangman(nbError); displayHangman(nbError);
System.out.println("mot a trouver " + this.curentLetter.wordBuilding); System.out.println("mot a trouver " + this.curentLetter.wordBuilding);
} }
//Permet au jeu de fonctionner et de se terminer
public void game(){ public void game(){
while(nbError<6 && !winCondition()){ while(nbError<6 && !winCondition()){
char letter = enter_word.getLetter(); char letter = enter_word.getLetter();
@@ -107,9 +109,10 @@ public class main {
showGame(); showGame();
} }
if (winCondition()){ if (winCondition()){
// tu gagnes
System.out.println("victoir (celui qui a écris a 5 de QI)"); System.out.println("victoir (celui qui a écris a 5 de QI)");
} }
else{ else{ //tu perds
System.out.println("ta perdu sale étron"); System.out.println("ta perdu sale étron");
System.out.println(" le bon mot était : " + this.word); System.out.println(" le bon mot était : " + this.word);
} }

Binary file not shown.

View File

@@ -1,18 +1,28 @@
import java.util.Random; import java.util.*;
import java.io.*;
public class word_search { public class word_search {
// Liste des mots
private static String[] WORDS = {
"singe", "google", "frapper", "haine", "dio", "java",
"felix vimalaratnam", "lebreton", "argent", "pauvre", "grocaillou"
};
/**
* Retourne un mot aléatoire du tableau WORDS
*/
public static String getRandomWord() { public static String getRandomWord() {
List<String> words = new ArrayList<>(); // Liste dynamique de mots
Random random = new Random(); Random random = new Random();
return WORDS[random.nextInt(WORDS.length)]; try { //lis le fichier, regarde si il existe avant de sélectionner un mot aléatoire
File file = new File("francais.txt");
Scanner scanner = new Scanner(file, "UTF-8");
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (!line.isEmpty()) { // ignore les lignes vides
words.add(line.toLowerCase());
}
}
scanner.close();
if (words.isEmpty()) {
System.out.println(" Aucun mot trouvé dans le fichier français.txt !");
return "erreur";
}
return words.get(random.nextInt(words.size()));
} catch (FileNotFoundException e) {
System.out.println(" Fichier 'français.txt' introuvable !");
return "erreur";
}
} }
} }