The objective of the program is to print a chessboard, with squares B (white) and N (black), ask for a row and a column and establish a bishop there.
So far so good, but the problem comes when you have to modify the board with asterisks in the boxes where you can move the bishop (diagonally):
B * B N B * B N
N B * B * B N B
B N B A B N B N
N B * B * B N B
B * B N B * B N
* B N B N B * B
B N B N B N B *
N B N B N B N B
The professor has skipped this problem, so I turn to this forum. How would you raise it? Code:
int posicion=8*(fila-1)+columna;
for(int i=1;i<=64;i++) {
if(i%2!=0){
if(i==posicion){
System.out.print("A ");
continue;
}
System.out.print("B ");
}else{
if(i==posicion){
System.out.print("A ");
continue;
}
System.out.print("N ");
}
if(i%8==0){
System.out.println();
}
}
I have not given matrices yet. Thanks
[EDIT] Only valid movements are valid, according to the actual movement of the bishop.