okay, what i am trying to do is to build a chess game. now i am at the begining of the code and i got stuck.
i created 6 packages for each piece and one package for the chessboard.
now the idea is to create a new array each time the player makes a turn..
package il.co.ChessInterface;
import il.co.King.King;
import il.co.Pawn.Pawn;
import il.co.Queen.Queen;
import il.co.Rook.Rook;
import java.io.Console;
public class ChessInterface {
public static void main(String[] arg){
ChessInterface chesspiece=new ChessInterface();
Console console=System.console();
System.out.println("what piece do you want to move?");
String chessPiece=console.readLine();
System.out.println("where do you want to move it to?(type column letter)");
String input=console.readLine();
char columnEnd=input.charAt(0);
System.out.println("where do you want to move it to?(type row number)");
int rowEnd=Integer.parseInt(console.readLine());
chesspiece [][] chessBoard;
chessBoard = new chesspiece [8][8];
chessBoard[1][0] pn1= new Pawn(a,2,columnEnd,rowEnd);
chessBoard[1][1] pn2= new Pawn(b,2,columnEnd,rowEnd);
chessBoard[1][2] pn3= new Pawn(c,2,columnEnd,rowEnd);
chessBoard[1][3] pn4= new Pawn(d,2,columnEnd,rowEnd);
chessBoard[1][4] pn5= new Pawn(e,2,columnEnd,rowEnd);
chessBoard[1][5] pn6= new Pawn(f,2,columnEnd,rowEnd);
chessBoard[1][6] pn7= new Pawn(g,2,columnEnd,rowEnd);
chessBoard[1][7] pn8= new Pawn(h,2,columnEnd,rowEnd);
chessBoard[columnEnd][rowEnd]=new Pawn(columnStart,rowStart, columnEnd, rowEnd);
}
}
in the second package , the pawn class..
package il.co.Pawn;
public class Pawn {
char columnEnd;
int rowEnd;
char columnStart;
int rowStart;
public Pawn(char columnStart,int rowStart, char columnEnd, int rowEnd){
this.columnEnd=columnEnd;
this.rowEnd=rowStart;
this.columnStart=rowStart2;
this.rowStart=rowStart;
}
static boolean isValidPawnMove(char columnStart, int rowStart, char columnEnd, int rowEnd)
{
what i am trying to do is to take info from the user and transfer a piece to another place in the array,
however, i dont know why and how to import informatio from one package to another..
and
i am not sure about how to transfer one object (chessPiece) into another place in teh array...
please help