package lab.observ; import java.util.*; import java.util.concurrent.*; import java.io.IOException; import lab.game.*; public class Observ{ public static void start() throws IOException, InterruptedException{ Scanner sc = new Scanner(System.in); Board mainBoard = new Board(); mainBoard.initPieces(); new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); mainBoard.printHelp(); sc.nextLine(); String player = "W"; String checkMate = null; boolean play = true; while(play){ while(true){ new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); mainBoard.printBoard(player); if( player.equals("W") ){ System.out.print("White "); }else{ System.out.print("Black "); } System.out.print("Player Move: "); String input = sc.nextLine(); if( input.split(" ").length == 2 ){ checkMate = mainBoard.checkMate(); if( checkMate == null ){ if( mainBoard.move(new StringBuilder(input.split(" ")[0]).reverse().toString(), new StringBuilder(input.split(" ")[1]).reverse().toString(), player) ){ break; } }else{ play = false; } } } if( player.equals("W") ){// Change PLayer player = "B"; }else{ player = "W"; } } new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); System.out.println("\t The Game is over"); if( checkMate.equals("W") ){ System.out.print("White "); }else{ System.out.print("Black "); } System.out.println("Player Won"); sc.close(); } }