| @@ -0,0 +1,51 @@ | |||||
| package tutorial; | |||||
| public class Declare_2D_Array_Chess { | |||||
| public static void main(String[] args) { | |||||
| String[][] chessboard = new String[8][8]; | |||||
| /*top two rows and columns | |||||
| 0 1 2 3 4 5 6 7 | |||||
| 0 R N B Q K B N R | |||||
| 1 P P P P P P P P */ | |||||
| chessboard[0][0] = "ROOK1"; | |||||
| chessboard[0][1] = "KNIGHT1"; | |||||
| chessboard[0][2] = "BISHOP1"; | |||||
| chessboard[0][3] = "QUEEN"; | |||||
| chessboard[0][4] = "KNIGHT"; | |||||
| chessboard[0][5] = "BISHOP2"; | |||||
| chessboard[0][6] = "KNIGHT2"; | |||||
| chessboard[0][7] = "ROOK2"; | |||||
| chessboard[1][0] = "PAWN1"; | |||||
| chessboard[1][1] = "PAWN2"; | |||||
| chessboard[1][2] = "PAWN3"; | |||||
| chessboard[1][3] = "PAWN4"; | |||||
| chessboard[1][4] = "PAWN5"; | |||||
| chessboard[1][5] = "PAWN6"; | |||||
| chessboard[1][6] = "PAWN7"; | |||||
| chessboard[1][7] = "PAWN8"; | |||||
| /*bottom two rows and columns | |||||
| 0 1 2 3 4 5 6 7 | |||||
| 6 r n b q k b n r | |||||
| 7 p p p p p p p p */ | |||||
| chessboard[7][0] = "rook1"; | |||||
| chessboard[7][1] = "knight1"; | |||||
| chessboard[7][2] = "bishop1"; | |||||
| chessboard[7][3] = "queen"; | |||||
| chessboard[7][4] = "king"; | |||||
| chessboard[7][5] = "bishop2"; | |||||
| chessboard[7][6] = "knight2"; | |||||
| chessboard[7][7] = "rook2"; | |||||
| chessboard[6][0] = "pawn1"; | |||||
| chessboard[6][1] = "pawn2"; | |||||
| chessboard[6][2] = "pawn3"; | |||||
| chessboard[6][3] = "pawn4"; | |||||
| chessboard[6][4] = "pawn5"; | |||||
| chessboard[6][5] = "pawn6"; | |||||
| chessboard[6][6] = "pawn7"; | |||||
| chessboard[6][7] = "pawn8"; | |||||
| } | |||||
| } | |||||