Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

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

1. ## 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;
int chin2[] = new int;
char bin[] = new char;
bin = 'Q'; bin = 'W'; bin = 'E'; bin = 'R'; bin = 'T'; bin = 'Y';
char a[] = new char;
int t[] = new int;
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 = chin+1;
} else if (t[x] == 2){
chin = chin+1;
} else if (t[x] == 3){
chin = chin+1;
} else if (t[x] == 4){
chin = chin+1;
} else if (t[x] == 5){
chin = chin+1;
} else if (t[x] == 6){
chin = chin+1;
}
if (d[x] == 1){
chin2 = chin2+1;
} else if (d[x] == 2){
chin2 = chin2+1;
} else if (d[x] == 3){
chin2 = chin2+1;
} else if (d[x] == 4){
chin2 = chin2+1;
} else if (d[x] == 5){
chin2 = chin2+1;
} else if (d[x] == 6){
chin2 = chin2+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;
}  Reply With Quote

3. ## 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.  Reply With Quote

4. ## 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));  Reply With Quote

5. ## 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  Reply With Quote