Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help so that the outputs are as follows with the commands; e . g . A 6 to B 5 will produce board [
Please help so that the outputs are as follows with the commands; eg A to B will produce board and move the char b to board If my logic is flawed please fix. this is my code and the image helps demonstrate it more.
import java.util.Scanner;
public class Checkers
static char blackPieces b;
static char whitePieces w;
static char empty ;
static char blackKing B;
static char whiteKing W;
static String exitCommand "exit";
static String viewCommand "view";
private static char board new char;
static Scanner scanner new ScannerSystemin;
private static void initialiseBoard
forint i ; i board.length;i
forint j ; j boardilength;j
ifij
ifi
boardij whitePieces;
else ifi
boardij blackPieces;
else
boardij empty;
else
boardij;
private static void displayBoard
forint i ; i board.length; i
System.out.print;
forint j ; j board.length fromCol fromCol boardlength
toRow toRow board.length toCol toCol boardlength
return false;
if boardtoRowtoCol empty
return false;
int rowDifference Math.abstoRow fromRow;
int colDifference Math.abstoCol fromCol;
if rowDifference colDifference
return false;
int rowChange toRow fromRow;
if rowChange
return false;
return true;
private static boolean isGameOver
boolean blackPiecesExist false;
boolean whitePiecesExist false;
for int i ; i board.length; i
for int j ; j boardilength; j
ifboardij blackKing boardij blackPieces
blackPiecesExist true;
else if boardij whiteKing boardij whitePieces
whitePiecesExist true;
if blackPiecesExist
System.out.printlnPlayer won";
return true;
else if whitePiecesExist
System.out.printlnPlayer won";
return true;
return false;
public static void mainString args
initialiseBoard;
displayBoard;
startGame;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started