What I'm suppose to do is give the user 5 inputs(pieces of chess), Rook,Bishop,King,Queen,Knight. and output them in a grid, I'm not sure how I would limit the user input to 5 times and print the rest of the grid with "."
my output results right now the grid below, but how can i get the userinput for Qb2(Queen, at column 2, at row 2?)) and out put it in the grid?and so on for the rest of the pieces ?
Output of the result I get vs the output of the sample given
Note: columns are from "A" to "H" and rows are starting from the bottom, so from "row 1" to row "8".
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
My code:
import java.util.Scanner;
class chessMoves
{
//MAIN CODE AT THE VERY BOTTOM OF THE CLASS
Scanner sc = new Scanner(System.in);
private String[][] grid = new String[8][8];
//target is x, so if x is at location in the grid, your program should determine if
// any of the pieces can move to that position.
private String king,queen,rook,bishop,knight,target;
public void chessPieces(){
//remember you're only using the peices in scanner for a string just for a test
//switch them to 2D Array so that i can as
System.out.println("Hello Guest00129, Welcome to Chess.");
System.out.println("In order to play this game, input pieces like below(cap;atilaized)");
System.out.println("Rook at column c and at row 5 then: Rc5");
System.out.println("Please enter a position for Rook");
rook = sc.nextLine();
System.out.println("Please enter a position for King");
king = sc.nextLine();
System.out.println("Please enter a position for Queen");
queen = sc.nextLine();
System.out.println("Please enter a position for Bishop");
bishop = sc.nextLine();
System.out.println("Please enter a position for Knight");
knight = sc.nextLine();
System.out.println("Please enter a position for Target(X) to move the peices to that position");
target = sc.nextLine();
}
public void printGrid(){
for(int row = 0; row <grid.length; row++){
for (int column = 0;column <grid[row].length; column++){
grid[row][column] = ".";
System.out.printf("%2s",grid[row][column] + " ");
}
System.out.println();
}
}
//get the userinput working first then make a file that gets the information for that userinput and outputs here
public void readChessPositions(){
}
//the file created from the method above read it print the grid here like printout here and show the possible
//positons that can attack
public void chessOutput(){
}
//method that prints the grid with the positiosn showed in the outputfile of chess moves
//print all empty spaces with dot(.) and the postiions
public static void main (String[] args){
chessMoves test1 = new chessMoves();
test1.chessPieces();
test1.printGrid();
}
}