Bonjour,
j'ai ce bout de code et j'ai eu un message d'erreur que j'arrive pas à résoudre (Il est toutefois dû à la dernière fonction choixNumerote).
Inutile de vous dire que je suis novice. Merci pour votre aide.
J'ai bien peur que la "rigueur" de Java ne vienne à bout de ma motivation toute fraîche !!!!



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
import java.util.Scanner;
		public class Mastermind_ho {
			static Scanner sc = new Scanner(System.in);
			static String [] TAB_REF_COLORS = {"rouge","jaune","vert","bleu","orange","blanc","violet","fuchsia"};
			static int NB_COLORS = 4;
			static int compteur=0;
 
 
			public static void main(String[] args) {	
 
// 1- Choisir aléatoirement 4 couleurs, de les stocker dans un tableau, de demander au joueur de choisir 4 couleurs, de les stocker dans un deuxième tableau.
//1.a- implementation de la fonction random :
// Pour utiliser generateRandomCombination, il suffit de recupérer le tableau de couleurs gténéré. 	
 
						String [] combinaisonSecrete = generateRandomCombination();
						for(int i=0;i<4;i++) {
							System.out.println(combinaisonSecrete[i]);
						}
 
						String [] combinaisonJoueur = choixNumerote();
						for(int i=0;i<4;i++) {
							System.out.println(combinaisonJoueur[i]);
						}
						sc.close();
				}
					// Generate random combination of 4 colors 
					static String [] generateRandomCombination() {
						String [] combination = new String[NB_COLORS];
						int currentPosition = 0;
						while(currentPosition!=NB_COLORS) {
							int indexRandom = (int)(Math.random()*TAB_REF_COLORS.length);
							String color = TAB_REF_COLORS[indexRandom];
							if(!isIn(color, combination)) {
								combination[currentPosition] = color;
								currentPosition++;
							}
						}
						return combination;
					}
 
					static boolean isIn(String iStringToFind, String [] iTab) {
						int size = iTab.length;
						for(int i=0;i<size;i++) {
							if(iStringToFind.equalsIgnoreCase(iTab[i])) return true;
						}
						return false;
				}
					static String [] choixNumerote() {
						String [] tabJoueur = new String[NB_COLORS];
						for(int i=0;i<NB_COLORS;i++) {
							System.out.println("Choisissez une couleur :");
							tabJoueur[i]=sc.nextLine();
								}
						compteur++;
						return tabJoueur;
						System.out.println("Il te reste : " + (12-compteur) + "tentative(s)");
						}
					}