import java.util.Scanner; public class DriverChess { public static void main (String [] args) { boolean moveValid = false; int sourceRow = -1; //Current location of chess piece int sourceColumn = -1; int destinationRow = -1; //Possible location to move the chess piece to int destinationColumn = -1; String typeOfChessPiece = null; Scanner in = new Scanner(System.in); ChessBoard aBoard = new ChessBoard(); while (true) { System.out.print("Current row: "); sourceRow = in.nextInt(); System.out.print("Current column: "); sourceColumn = in.nextInt(); System.out.print("Destination row: "); destinationRow = in.nextInt(); System.out.print("Destination column: "); destinationColumn = in.nextInt(); in.nextLine(); //Remove the EOL from the input stream before getting a String input //Only check if move is valid if the source and destination location are inside the board. if (aBoard.outOfBounds(sourceRow,sourceColumn,destinationRow,destinationColumn) == false) { System.out.print("Type of piece to move e.g. king,queen,knight,rock,black pawn,white pawn etc.: " ); typeOfChessPiece = in.nextLine(); moveValid = aBoard.isMoveValid(sourceRow,sourceColumn,destinationRow,destinationColumn,typeOfChessPiece); System.out.print("Moving a " + typeOfChessPiece + " from location(row/column)=(" + sourceRow + "/" + sourceColumn + ") to location(row/column)=(" + destinationRow + "/" + destinationColumn + ") "); if (moveValid == true) System.out.println("is a valid move."); else System.out.println("is not a valid move."); } else { System.out.println("Out of bounds"); } System.out.println("Hit enter to continue: "); in.nextLine(); } } }