This commit is contained in:
Rémi Heredero 2021-11-20 15:04:48 +01:00
parent 30faa26274
commit 1acb2bde6b
4 changed files with 28 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +1,6 @@
package lab6;
import hevs.graphics.FunGraphics;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
public class HangMan {
final int MAX_STEPS = 8;
@ -80,7 +77,6 @@ public class HangMan {
public static void main(String[] args) {
HangMan hang = new HangMan();
hang.loadList("C:/Users/remi/OneDrive/Documents/Cours/05-HEVS/S1fb/informatic/labo/vscode/Labo/src/lab6/french_common_words.csv");
while (true) {
hang.word.askSecretWord();
hang.current_step = 0;
@ -99,25 +95,6 @@ public class HangMan {
}
}
public String[] loadList(String filePath) {
String[] wordList;
try {
BufferedReader bf = new BufferedReader(new FileReader(filePath));
ArrayList < String > al = new ArrayList < String > ();
while (bf.ready()) {
String[] c = bf.readLine().split(";");
al.add(c[0]);
}
wordList = al.stream().toArray(String[]::new);
System.out.println("[Dictionary loaded with " + wordList.length + " words]");
bf.close();
return wordList;
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
}
// comentaire pour le fun

View File

@ -1,5 +1,8 @@
package lab6;
import java.text.Normalizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
public class WordManager {
private String secretWord = "";
@ -46,4 +49,29 @@ public class WordManager {
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s;
}
private String randomWord() {
loadList("C:/Users/remi/OneDrive/Documents/Cours/05-HEVS/S1fb/informatic/labo/vscode/Labo/src/lab6/french_common_words.csv");
String s = "";
return s;
}
private String[] loadList(String filePath) {
String[] wordList;
try {
BufferedReader bf = new BufferedReader(new FileReader(filePath));
ArrayList < String > al = new ArrayList < String > ();
while (bf.ready()) {
String[] c = bf.readLine().split(";");
al.add(c[0]);
}
wordList = al.stream().toArray(String[]::new);
System.out.println("[Dictionary loaded with " + wordList.length + " words]");
bf.close();
return wordList;
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
}