Je voudrais savoir comment puis-je trier mes tableau , je suis bloqué à cet endroit, merci bien pour votre aide !
Voici mon code :
stimulus
answer
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
78
79
80
81
82
83
84
85
86
87 public class Stimulus{ public String mot; private String stringOfAnswers; public int numberOfAnswers = 0; Stimulus(String s1, String s2){ mot = s1; stringOfAnswers = s2; } public void calculnOA(){ int compteurDeBarres = 0; for (int i = 0; i < stringOfAnswers.length(); i++){ if (stringOfAnswers.charAt(i) == '|'){ compteurDeBarres++; } } numberOfAnswers = compteurDeBarres / 2; } public void buildArray(){ boolean readingFreq = false;//indique si nous sommes en train de lire la frequence d'une reponse int indexOfArray = 0; int convertMultiplier = 1;//multiplicateur pour la conversion de char en int for(int i = 0; i < stringOfAnswers.length(); i++){ if (!readingFreq){ if (stringOfAnswers.charAt(i) != '|'){ (answers[indexOfArray]).mot = mot + stringOfAnswers.charAt(i); } else{ readingFreq = true; indexOfArray++; } } else { if (stringOfAnswers.charAt(i) != '|'){ (answers[indexOfArray]).frequence += ( (int)(stringOfAnswers.charAt(i)) - (int)'0') * convertMultiplier; convertMultiplier *= 10; } else { convertMultiplier = 1; readingFreq = false; } } }//fin du for }//fin de la methode public Answer [] answers = new Answer [numberOfAnswers]; public int frequence(){ int a = 0; for(int i = 0; i < answers.length ; i++) a += (answers[i]).frequence ; return a; } public void answerMe(int seuil){ for (int i = 0; i < answers.length; i++){ if ((answers[i]).frequence > seuil){ System.out.print((answers[i]).mot + "|" + (answers[i].frequence) + "|"); } } System.out.println(" "); } public boolean isStimulusOf(String s){ for (int i = 0; i < answers.length; i++){ if ( s.equals( (answers[i]).mot)) return true; } return false; } public int frequencyOf(String s){ for (int i = 0; i < answers.length; i++){ if ( s.equals((answers[i]).mot)) return (answers[i]).frequence; // inutile d'appeler isStimulusOf } return 0 ; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 public class Answer{ public String mot = null; public int frequence = 0; }
Partager