Commit 25e80531 authored by hamed's avatar hamed

improve console intraction with app (add raw and column names in board for easier interaction)

parent 7fa5c498
...@@ -91,8 +91,10 @@ public class Board { ...@@ -91,8 +91,10 @@ public class Board {
@Override @Override
public String toString() { public String toString() {
String str = ""; String str = " a b c d e f g h\n";
str = str + "------------------\n";
for (int j = 0 ; j < 8 ; j++){ for (int j = 0 ; j < 8 ; j++){
str = str+(j+1)+"|";
for (int i = 0 ; i < 7 ; i++){ for (int i = 0 ; i < 7 ; i++){
if(board[i][j]!=null) { if(board[i][j]!=null) {
str = str + board[i][j] + " "; str = str + board[i][j] + " ";
...@@ -101,11 +103,14 @@ public class Board { ...@@ -101,11 +103,14 @@ public class Board {
str = str + "0 "; str = str + "0 ";
} }
if(board[7][j]!=null) { if(board[7][j]!=null) {
str = str + board[7][j] + "\n"; str = str + board[7][j];
} }
else else
str = str + "0\n"; str = str + "0";
str = str+"|"+(j+1)+"\n";
} }
str = str + "------------------\n";
str = str+ " a b c d e f g h\n";
return str; return str;
} }
} }
...@@ -33,13 +33,14 @@ public class Main { ...@@ -33,13 +33,14 @@ public class Main {
continue; continue;
} }
if (b.getMove(x, y, dx, dy)) { if (b.getMove(x, y, dx, dy)) {
System.out.println("Moved"); System.out.println(splt[0]+" Moved to "+splt[1]);
whichMove = false; whichMove = false;
} else { } else {
System.out.println("Incorrect Move, Please insert Correct Movement"); System.out.println("Incorrect Move, Please insert Correct Movement");
} }
} }
} }
if(!whichMove)
System.out.println(b); System.out.println(b);
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
if(whichMove) continue; if(whichMove) continue;
...@@ -61,12 +62,13 @@ public class Main { ...@@ -61,12 +62,13 @@ public class Main {
continue; continue;
} }
if(b.getMove(x,y,dx,dy)){ if(b.getMove(x,y,dx,dy)){
System.out.println("Moved"); System.out.println(splt[0]+" Moved to "+splt[1]);
whichMove = true; whichMove = true;
}else { }else {
System.out.println("Incorrect Move, Please insert Correct Movement"); System.out.println("Incorrect Move, Please insert Correct Movement");
} }
} }
if(whichMove)
System.out.println(b); System.out.println(b);
} }
} }
......
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