Commit 59b24e08 authored by Omid Sayfun's avatar Omid Sayfun

Tidy Up

parent 6240c6aa
import java.util.*;
import java.util.concurrent.*;
import java.io.IOException;
import lab.observ.*;
public class Main{
public static void main(String[] args) throws IOException, InterruptedException{
Scanner sc = new Scanner(System.in);
Board mainBoard = new Board();
mainBoard.initPieces();
// mainBoard.printHelp();
String player = "W";
for(int i = 0; i < 500; i++){
while(true){
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
mainBoard.printBoard();
if( player.equals("W") ){
System.out.print("White ");
}else{
System.out.print("Black ");
}
System.out.print("Player Move: ");
String input = sc.nextLine();
// Check if input is valid
if( mainBoard.move(input.split(" ")[0], input.split(" ")[1], player) ){
break;
}
}
if( player.equals("W") ){// Change PLayer
player = "B";
}else{
player = "W";
}
try{
Observ.start();
}catch(IOException e){
e.printStackTrace();
}
sc.close();
}
}
package lab.game;
import java.util.*;
public class Bishop extends Piece{
......
package lab.game;
import java.util.*;
public class Board{
......
package lab.game;
import java.util.*;
public class King extends Piece{
......
package lab.game;
import java.util.*;
public class Knight extends Piece{
......
package lab.game;
import java.util.*;
public class Pawn extends Piece{
......
package lab.game;
import java.util.*;
public abstract class Piece{
protected int y;
protected char x;
......
package lab.game;
import java.util.*;
public class Queen extends Piece{
......
package lab.game;
import java.util.*;
public class Rook extends Piece{
......
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();
// mainBoard.printHelp();
String player = "W";
for(int i = 0; i < 500; i++){
while(true){
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
mainBoard.printBoard();
if( player.equals("W") ){
System.out.print("White ");
}else{
System.out.print("Black ");
}
System.out.print("Player Move: ");
String input = sc.nextLine();
// Check if input is valid
if( mainBoard.move(input.split(" ")[0], input.split(" ")[1], player) ){
break;
}
}
if( player.equals("W") ){// Change PLayer
player = "B";
}else{
player = "W";
}
}
sc.close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment