Toon posts:

[Java] Mastermind-probleem

Pagina: 1
Acties:
  • 152 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Ik ben bezig met een applet die in staat is Mastermind te spelen. Hiervoor heb ik een algoritme bedacht en de methods die nodig zijn voor dit algoritme in een klasse gegoten.
Dr zit daar echter ergens een fout in, waardoor ik 100(:() foutmeldingen krijg. Ik kan de fout alleen niet vinden.
Zien jullie misschien wat er mis gaat?

Hier staat de source.

Alvast bedankt :)

  • chem
  • Registratie: Oktober 2000
  • Laatst online: 27-08 13:53

chem

Reist de wereld rond

/14 is niet je persoonlijke debugginghelpdesk... geef minstens aan wat er fout gaat en wat je vermoed dat er verkeerd gaat

Klaar voor een nieuwe uitdaging.


Verwijderd

Topicstarter
Dat snap ik dus juist niet...
Ik krijg bij regeltjes als:

String variabele;

zo ongeveer steevast de foutmelding:

String: not a statement

  • Alarmnummer
  • Registratie: Juli 2001
  • Laatst online: 09-07-2024

Alarmnummer

-= Tja =-

Op vrijdag 05 oktober 2001 11:05 schreef minne het volgende:
Ik ben bezig met een applet die in staat is Mastermind te spelen. Hiervoor heb ik een algoritme bedacht en de methods die nodig zijn voor dit algoritme in een klasse gegoten.
Dr zit daar echter ergens een fout in, waardoor ik 100(:() foutmeldingen krijg. Ik kan de fout alleen niet vinden.
Zien jullie misschien wat er mis gaat?

Hier staat de source.

Alvast bedankt :)
We zijn ook niet een beetje lui he? :)

Verwijderd

Ik komt niet eens bij je source !!!

  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
JavaRules: bla
Zo zo dat is nog eens een interessante username. Welkom op /14 :) .

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Algorithm.java:21: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    numberPositions = positions;

Algorithm.java:121: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    int[] codeArray1 = new int[numberPositions];
                     ^
Algorithm.java:122: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    int[] codeArray2 = new int[numberPositions];

Algorithm.java:157: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    for (i = 0; 1 < numberPositions; i++)

Domme type fout. Je hebt gedeclareerd:
private int numberPostions;
code:
1
2
3
4
Algorithm.java:29: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    double sizeList = Math.pow(numberColors, numberPositions);

Idem
code:
1
2
3
4
5
                               ^
Algorithm.java:30: possible loss of precision
found   : double
required: int
    int[] codeList = new int[sizeList];

sizeList is een double. De grootte van een array moet een integer zijn.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Algorithm.java:39: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < sizeList; i++)
       ^
Algorithm.java:39: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < sizeList; i++)
            ^
Algorithm.java:39: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < sizeList; i++)

Variabele i is niet gedeclareerd.
code:
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
Algorithm.java:63: cannot resolve symbol
symbol  : variable nextCode
location: class Algorithm
    nextCode = digit1 + (10 * digit2) + (100 * digit3) + (1000 * digit4) + (10000 * digit5);
    ^
Algorithm.java:64: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    sizeList[i] = nextCode;

Algorithm.java:64: array required, but double found
    sizeList[i] = nextCode;
          ^
Algorithm.java:64: cannot resolve symbol
symbol  : variable nextCode
location: class Algorithm
    sizeList[i] = nextCode;
              ^
Algorithm.java:71: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
       ^
Algorithm.java:71: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
            ^
Algorithm.java:71: cannot resolve symbol
symbol  : variable sizeList
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
               ^
Algorithm.java:71: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
                     ^
Algorithm.java:73: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    int black = checkBlackPins(code, codeList[i]);
                                ^
Algorithm.java:74: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    int white = checkWhitePins(code, codeList[i]);
                                ^
Algorithm.java:75: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    if ((10 * black) + white != evaluation) killCode(codeList[i]);
                                            ^
Algorithm.java:79: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
       ^
Algorithm.java:79: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
            ^
Algorithm.java:79: cannot resolve symbol
symbol  : variable sizeList
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
               ^
Algorithm.java:79: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
                     ^
Algorithm.java:81: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    if (codeList[i] != 0) newGuess = codeList[i];
             ^
Algorithm.java:81: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    if (codeList[i] != 0) newGuess = codeList[i];
                                ^
Algorithm.java:96: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
       ^
Algorithm.java:96: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
            ^
Algorithm.java:96: cannot resolve symbol
symbol  : variable sizeList
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
               ^
Algorithm.java:96: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i <= sizeList; i++)
                     ^
Algorithm.java:98: cannot resolve symbol
symbol  : variable i
location: class Algorithm
     if (codeList[i] == code) codeList[i] = 0;
              ^
Algorithm.java:98: cannot resolve symbol
symbol  : variable i
location: class Algorithm
     if (codeList[i] == code) codeList[i] = 0;
                             ^
Algorithm.java:108: cannot resolve symbol
symbol  : variable guess
location: class Algorithm
    guess = 10 * a + a;
    ^
Algorithm.java:109: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 2; i <= numberPositions; i++)
       ^
Algorithm.java:109: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 2; i <= numberPositions; i++)
            ^
Algorithm.java:109: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    for (i = 2; i <= numberPositions; i++)
               ^
Algorithm.java:109: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 2; i <= numberPositions; i++)
                          ^
Algorithm.java:110: cannot resolve symbol
symbol  : variable guess
location: class Algorithm
    guess = guess + (Math.pow(10, i - 1));
    ^
Algorithm.java:110: cannot resolve symbol
symbol  : variable guess
location: class Algorithm
    guess = guess + (Math.pow(10, i - 1));
          ^
Algorithm.java:110: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    guess = guess + (Math.pow(10, i - 1));
                        ^
Algorithm.java:111: cannot resolve symbol
symbol  : variable guess
location: class Algorithm
    return guess;

         ^
                     ^
Algorithm.java:124: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
       ^
Algorithm.java:124: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
            ^
Algorithm.java:124: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
              ^
Algorithm.java:124: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
                         ^
Algorithm.java:128: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp12 = temp1.subString(i, i);
                          ^
Algorithm.java:128: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp12 = temp1.subString(i, i);
                             ^
Algorithm.java:129: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp22 = temp2.subString(i, i);
                          ^
Algorithm.java:129: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp22 = temp2.subString(i, i);
                             ^
Algorithm.java:132: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    codeArray1[i] = temp13;
             ^
Algorithm.java:133: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    codeArray2[i] = temp23;
             ^
Algorithm.java:137: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
       ^
Algorithm.java:137: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
            ^
Algorithm.java:137: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
              ^
Algorithm.java:137: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; i < numberPositions; i++)
                         ^
Algorithm.java:139: cannot resolve symbol
symbol  : variable j
location: class Algorithm
    for (j = 0; j < numberPositions; j++)
         ^
Algorithm.java:139: cannot resolve symbol
symbol  : variable j
location: class Algorithm
    for (j = 0; j < numberPositions; j++)
            ^
Algorithm.java:139: cannot resolve symbol
symbol  : variable numberPositions
location: class Algorithm
    for (j = 0; j < numberPositions; j++)
                ^
Algorithm.java:139: cannot resolve symbol
symbol  : variable j
location: class Algorithm
    for (j = 0; j < numberPositions; j++)
                           ^
Algorithm.java:141: cannot resolve symbol
symbol  : variable i
location: class Algorithm
      if (codeArray1[i] == codeArray2[j])
                 ^
Algorithm.java:141: cannot resolve symbol
symbol  : variable j
location: class Algorithm
      if (codeArray1[i] == codeArray2[j])
                            ^
Algorithm.java:144: cannot resolve symbol
symbol  : variable j
location: class Algorithm
        codeArray2[j] = -1;

Idem.
code:
1
2
3
4
Algorithm.java:148: cannot resolve symbol
symbol  : method getBlackPins  (int,int)
location: class Algorithm
    whitePins -= getBlackPins(code1, code2);

Moet check zijn.
code:
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
Algorithm.java:157: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; 1 < numberPositions; i++)
       ^
             ^
Algorithm.java:157: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    for (i = 0; 1 < numberPositions; i++)
                         ^
Algorithm.java:161: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp12 = temp1.subString(i, i);
                          ^
Algorithm.java:161: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp12 = temp1.subString(i, i);
                             ^
Algorithm.java:162: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp22 = temp2.subString(i, i);
                          ^
Algorithm.java:162: cannot resolve symbol
symbol  : variable i
location: class Algorithm
    String temp22 = temp2.subString(i, i);

Weer allemaal niet gedeclareerd.

Was dat nou zo moeilijk?

1. Je bent lui.
2. Je programmeert slordig.

Conclusie: doe er wat aan :)

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

Op vrijdag 05 oktober 2001 21:02 schreef mbravenboer het volgende:

Was dat nou zo moeilijk?

1. Je bent lui.
2. Je programmeert slordig.

Conclusie: doe er wat aan :)
* wasigh van de week
begin met een klein programma, zorg dat dat loopt, maak dan bewust fouten en kijkt wat de compiler voor foutmeldingen geeft zo leer je snel debuggen
(een IDE zoals JBuilder helpt bij het debuggen ;))

  • Albinoraptor
  • Registratie: Juli 2000
  • Laatst online: 16:41
Ja ik ken Minne. Hij is gewoon ontzettend lui.
Dus niet meer reageren op die knuppel. >:)
Pagina: 1