package Main; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner in = new Scanner(System.in); Board b = new Board(); System.out.println(b); // if(b.getMove(1,1,1,3)){ // System.out.println("Okey"); // } // System.out.println(b); boolean whichMove = true; boolean isBlackPrintBoard = false; boolean isWhitePrintBoard = false; while (true){ if(whichMove) { System.out.println("White Turn.... insert a move in a line"); String str = in.nextLine(); String splt[] = str.split(" "); if (splt.length == 1) { int dx = splt[0].charAt(0) - 'a'; int dy = splt[0].charAt(1) - '1'; ArrayList moves = b.getMoves(dx, dy); printMoves(moves); } else if (splt.length == 2) { int x = splt[0].charAt(0) - 'a'; int y = splt[0].charAt(1) - '1'; int dx = splt[1].charAt(0) - 'a'; int dy = splt[1].charAt(1) - '1'; if(b.getColor(x,y)!=1) { System.out.println("Incorrect Move Color, Please insert Correct Movement"); continue; } if (b.getMove(x, y, dx, dy)) { System.out.println(splt[0]+" Moved to "+splt[1]); whichMove = false; isWhitePrintBoard = true; } else { System.out.println("Incorrect Move, Please insert Correct Movement"); } } } if(isWhitePrintBoard) { System.out.println(b); isWhitePrintBoard = false; } //-------------------------------------------------------------------------- if(whichMove) continue; System.out.println("Black Turn.... insert a move in a line"); String str = in.nextLine(); String splt[] = str.split(" "); if(splt.length==1){ int dx = splt[0].charAt(0)-'a'; int dy = splt[0].charAt(1)-'1'; ArrayList moves = b.getMoves(dx,dy); printMoves(moves); }else if(splt.length==2){ int x = splt[0].charAt(0)-'a'; int y = splt[0].charAt(1)-'1'; int dx = splt[1].charAt(0)-'a'; int dy = splt[1].charAt(1)-'1'; if(b.getColor(x,y)!=2) { System.out.println("Incorrect Move Color, Please insert Correct Movement"); continue; } if(b.getMove(x,y,dx,dy)){ System.out.println(splt[0]+" Moved to "+splt[1]); whichMove = true; isBlackPrintBoard=true; }else { System.out.println("Incorrect Move, Please insert Correct Movement"); } } if(isBlackPrintBoard) { System.out.println(b); isBlackPrintBoard = false; } } } public static void printMoves(ArrayList moves){ for(int m[] : moves){ System.out.print((char)(m[0]+'a')+""+(m[1]+1)+","); } System.out.println(); } }