hey guys ...i m making a project of "CHESS GAME".....
in which to identify any pieces of chess board ,i had used described mechanism....(see code of array)
...
but it actually not working...it takes garbage value...it is working only for the "Rook"...
i can't understand this behavior...so plz help me 2 find out d bugs..

you can also give some more efficient mechanism for identify d piece on chess board...

if you knw any thing which can help me 2 make chess game then plz post it...hurry up!!

thnk u...
mundvawala
<EMAIL SNIPPED>

jPieces = new String[8][8];
                jPieces[0][0] = "bRook";
                jPieces[0][1] = "bKnight";
                jPieces[0][2] = "bBishop";
                jPieces[0][3] = "bQueen";
                jPieces[0][4] = "bKing";
                jPieces[0][5] = "bBishop";
                jPieces[0][6] = "bKnight";
                jPieces[0][7] = "bRook";
                jPieces[1][0] = "bPawn";
                jPieces[1][1] = "bPawn";
                jPieces[1][2] = "bPawn";
                jPieces[1][3] = "bPawn";
                jPieces[1][4] = "bPawn";
                jPieces[1][5] = "bPawn";
                jPieces[1][6] = "bPawn";
                jPieces[1][7] = "bPawn";
               
                jPieces[6][0] = "wPawn";
                jPieces[6][1] = "wPawn";
                jPieces[6][2] = "wPawn";
                jPieces[6][3] = "wPawn";
                jPieces[6][4] = "wPawn";
                jPieces[6][5] = "wPawn";
                jPieces[6][6] = "wPawn";
                jPieces[6][7] = "wPawn";
                jPieces[7][0] = "wRook";
                jPieces[7][1] = "wKnight";
                jPieces[7][2] = "wBishop";
                jPieces[7][3] = "wQueen";
                jPieces[7][4] = "wKing";
                jPieces[7][5] = "wBishop";
                jPieces[7][6] = "wKnight";
                jPieces[7][7] = "wRook";

for(int x=0;x<8;x++)
{
	for(int y=0;y<8;y++)
 	System.out.println(jPieces[x][y]);
}

Edited 6 Years Ago by peter_budo: No emails in posts allowed. Do not mark your post as code snippeds if you asking question.

ola,

since no one else is gonna reply I might aswell give it a shot ^_^ hehe

i can't understand exactly whats wrong, it compiles and works on my netbeans?
can you plz try and explain in another way?

krefie

hi, iam g. vijaya durga i would like to do a small java project will u help me? i hope that u can allow me to get some suggestions from u. thanx waiting for ur reply.

@Krefie:
actually sir when i m run this code...it only jst print
rook
pawn
null
null
null
rook
pawn

bt actullay it should have 2 print all the elements...

i want to use this mechanism 2 identify particular piece in such a manner tht
i will try to get the integer value of the mouseClikedEvent...and compare dis cordinate values with d given jpieces array..

suppose cordinate values are 2 3
then jpieces[2][3] will b checkd if it is "pawn"or etc then follow respectiv rules for it....

if still you can't understand then plz contact me on my email address ..where i will send you whole code of my project....
thank you sir
<EMAIL SNIPPED>

Edited 6 Years Ago by peter_budo: Keep It On The Site - Do not post asking for an answer to be sent to you via email or PM.

System.out.println(jPieces[x][y])

Try debugging your code by changing the above to:
System.out.println("x=" + x + ", y=" + y + " " + jPieces[x][y])
That should show you the problem.

Also, you put "pieces" in some of the elements of the array. The rest are unfilled, so they are null. I would suggest to fill all the array with empty Strings "" in order to avoid the NullPointerException.
Then put to the elements you want the "pieces".

And if you want to compare them use the equals method:

if (jPieces[x][y].equals("wPawn")) {

}

Also whenever you move a piece, put an empty String "" at the previous position after you have moved the piece to the new position

@NormR1 : thank you very much...it help me a lot....
@javaAddict: thank you very much.... for giving me such a nice clue for comparing pieces....

@ vijjue.

help with what boet? you can post your codeing but we can't do the homework for you...if you ask for help your gonna need to start your own thread and plz dont expect any help other than tips & tricks & some error detection, we can't write the code for you as that would be pointless.

@mundvawala

Everything sorted then m8?

regards krefie

This question has already been answered. Start a new discussion instead.