# Need help on decoding what this part of the code does

• December 13th, 2013, 04:22 AM
aude922000
Need help on decoding what this part of the code does
I have been trying to decode a program that was made but i'm having a hard time understanding what this part of the code does can anyone tell me what each variable does?
i think its for the checking part of the game but i'm unsure what chin and chin2 does as well as int t,x,a specifically
i'm sorry that the part i don't understand is quite long and thank you for your help in advance

int chin[] = new int[6];
int chin2[] = new int[6];
char bin[] = new char[6];
bin[0] = 'Q'; bin[1] = 'W'; bin[2] = 'E'; bin[3] = 'R'; bin[4] = 'T'; bin[5] = 'Y';
char a[] = new char[4];
int t[] = new int[4];
for (int x = 0;x<4;x++){
a[x] = (f.charAt(x));
}
for (int i = 0; i< 4;i++){
for (int tim = 0; tim<6;tim++){
if (a[i] == bin[tim]){
t[i] = tim +1;
}}
}for (int x = 0;x<4;x++){
if (t[x] == 1){
chin[0] = chin[0]+1;
} else if (t[x] == 2){
chin[1] = chin[1]+1;
} else if (t[x] == 3){
chin[2] = chin[2]+1;
} else if (t[x] == 4){
chin[3] = chin[3]+1;
} else if (t[x] == 5){
chin[4] = chin[4]+1;
} else if (t[x] == 6){
chin[5] = chin[5]+1;
}
if (d[x] == 1){
chin2[0] = chin2[0]+1;
} else if (d[x] == 2){
chin2[1] = chin2[1]+1;
} else if (d[x] == 3){
chin2[2] = chin2[2]+1;
} else if (d[x] == 4){
chin2[3] = chin2[3]+1;
} else if (d[x] == 5){
chin2[4] = chin2[4]+1;
} else if (d[x] == 6){
chin2[5] = chin2[5]+1;
}
}

for (int x = 0; x <= 3; x++) {
if (d[x] == t[x]) {
v++;
}
}

for (int x = 0;x<6;x++){
if (chin[x] <= chin2[x]){
count2 = count2 + chin[x];
} else {
count2 = count2 + chin2[x]; }
} count2 = count2 - v;
}
• December 13th, 2013, 06:06 AM
GregBrannon
Re: Need help on decoding what this part of the code does
Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

Don't expect an answer until you've posted correctly, and then ask a question that shows you've made some effort. For example, show what you think the code does and ask us if we agree. You might also try running it. We won't help you if it appears you've just copied code from the Internet and want to understand it so that you can comment it before you turn it in as your own.
• December 13th, 2013, 07:14 AM
Norm
Re: Need help on decoding what this part of the code does
A useful technique for finding out what some code does is to add lots of println statements to print out the values of the variables that are used so you can see what the computer is doing as it executes the code.
For arrays:
System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
• December 13th, 2013, 08:07 AM
aude922000
Re: Need help on decoding what this part of the code does
Thanks for that technique it helped me figure out what it does ill be sure to remember it next time. sorry for posting it wrong and still helping me though ill be sure to try to post a question correctly next time