Bonjour à tous,

Pour un exercice, j'ai fais un pendu qui fonctionne très bien mais impossible d'avoir le bon nombre de tirets correspondant au nombre de caractères à chercher dans la librairie.

Le nombre de tirets correspond au nombre de caractères dans le plus grand mot c'est à dire 14 et ça pose problème.

Voici mes sources :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Hangman2 {
 
    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
 
        String radmWord = String.copyValueOf (MOOC.motAuSort());
 
        int radmNumber = (int) Math.ceil(Math.random() * radmWord);
        int counter = 10;
 
        char[] genRadmLetter = radmWord.toCharArray();
        char[] genRadmLetter2 = radmWord.toCharArray();
        for (int x = 0; x < genRadmLetter.length; x++) {
            genRadmLetter[x] = '-';
        }
 
        Set<Character> guesses = new HashSet<Character>();
        do {
 
            System.out.println("Entrez une lettre");
 
            System.out.println(String.valueOf(genRadmLetter));
            char guessedLetter = Input.next().charAt(0);
 
            if (guesses.contains(guessedLetter)) {
 
                System.out.println("Vous avez déjà utilisé cette lettre");
 
            } else {
 
                guesses.add(guessedLetter);
                boolean found = false;
               for (int rw = 0; rw < genRadmLetter2.length; rw++) {
 
                    if (genRadmLetter2[rw] == guessedLetter) {
 
                        genRadmLetter[rw] = guessedLetter;
                        found = true;
 
                    }
 
                }
 
                if (!found) {
                    System.out.println("Mauvaise lettre, merci de réessayer");
                    counter = counter - 1;
                    System.out.println("Tentatives restantes: " + counter);
                }
 
            }
 
            boolean result = Arrays.equals(genRadmLetter, genRadmLetter2);
            if (result == true) {
                break;
            }
 
            if (counter == 0) {
                break;
            }
 
        } while (counter != 0);
 
        if (counter == 0) {
            System.out.println("Vous avez perdu le mot était: " + radmWord);
        } else {
            System.out.println("Bravo");
            System.out.println("Il vous restait " + counter +" tentatives");
        }
 
    }
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public class MOOC{    
    private static java.util.Scanner scan;
    private static String[] listeMots =
    {"MATERIAU      ", "POLITIQUE     ", "FAVORISER     ", "EXTERIEUR     ", 
     "FINANCER      ", "TRADITION     ", "CONSULTER     ", "POSSIBILITE   ", 
     "POURCENTAGE   ", "FAVORABLE     ", "ORDINATEUR    ", "FONCTIONNER   ", 
     "EXPANSION     ", "LOGICIEL      ", "CONTINUE      ", "LIQUIDATION   ", 
     "BOURSIER      ", "RACHETER      ", "ALIMENTAIRE   ", 
     "ALLEMANDE     ", "INVESTISSEUR  ", "OBLIGATOIRE   ", 
     "UTILISATION   ", "IMMEUBLE      ", "NECESSAIRE    ", 
     "AUGMENTER     ", "BENEFICIER    ", "TRAVAILLER    ", "DIRECTIVE     ", 
     "GENERALE      ", "CONSOLIDATION ", "CORRECTION    ", 
     "INTERVENTION  ", "COMPETITIVITE ", "FONCTION      ", 
     "MINISTRE      ", "PERMANENTE    ", "NUMERIQUE     ", "CROISSANCE    ", 
     "CONSTRUCTEUR  ", "MANAGEMENT    ", "EVIDEMMENT    ", "INSTITUTION   ", 
     "MOUVEMENT     ", "PUREMENT      ", "NATIONAL      ", "INITIATIVE    ", 
     "ENORMEMENT    ", "RETROUVER     ", "INVESTISSEUR  ", "ACCUEILLIR    ", 
     "PERSPECTIVE   ", "STRATEGIQUE   ", "COMPARAISON   ", "PREFERENCE    ", 
     "PRODUCTEUR    ", "CHIMIQUE      ", "RISQUER       ", 
     "TENDANCE      ", "SPECIALISTE   ", "ATTENTION     ", 
     "SPECIALISEE   ", "FONCTIONNEMENT", "LARGEMENT     ", "BEAUCOUP      ", 
     "GLOBALEMENT   ", "RECUPERER     ", "VIOLENCE      ", "PREVENTION    ", 
     "CONSTATER     ", "CONDUITE      ", "CONSACRER     ", "BENEFICE      ", 
     "ASSURANCE     ", "ASSUREUR      ", "JUSTIFIE      ", "UNIVERSITE    ", 
     "FONDATION     ", "RESPECTER     ", "SPECIALISER   ", "CONCLUSION    ", 
     "NOTATION      "};
    static{
    scan=new java.util.Scanner(System.in);
    scan.useLocale(java.util.Locale.ENGLISH);
    }
    public static double readDouble(){
    double res = scan.nextDouble();
    scan.nextLine();
    return res;
    }
    public static void pause(double n){
    try{
        Thread.sleep((long)(n* 1000));
    }catch(InterruptedException ie){
        throw new RuntimeException();
    }
    }
    public static String readString(){
    String res = scan.nextLine();
    return res;
    }
    public static int readInt(){
    int res = scan.nextInt();
    scan.nextLine();
    return res;
    }
     public static boolean readBoolean(){
    boolean res = scan.nextBoolean();
    scan.nextLine();
    return res;
    }
    public static boolean isDigit(char c){
    return Character.isDigit(c);
    }
    public static char readChar(){
    char res =  scan.nextLine().charAt(0);
       return res;
    }
    public static int auSort(int min, int max){
        return (int) (Math.random()*(max-min+1)+min);
   }
 
    public static char[] motAuSort(){
    return listeMots[(int) (Math.random()*(listeMots.length+1))].toCharArray();
    }
}
Quelqu'un saurait-il m'indiquer d'où vient le problème ?

Merci d'avance pour vos réponses