Commit 36de7cba authored by amir's avatar amir

Printing turns and pass

parent 5ad9f2e8
...@@ -44,4 +44,10 @@ public class Console extends Display { ...@@ -44,4 +44,10 @@ public class Console extends Display {
inputs[0] = f[2] - 'A' + 1; inputs[0] = f[2] - 'A' + 1;
return inputs; return inputs;
} }
@Override
public String printing(String toPrint, int playerNumber) {
System.out.println(super.printing(toPrint, playerNumber));
return super.printing(toPrint, playerNumber);
}
} }
...@@ -19,4 +19,10 @@ public class Display { ...@@ -19,4 +19,10 @@ public class Display {
int[] input = new int[2]; int[] input = new int[2];
return input; return input;
} }
public String printing(String toPrint, int playerNumber){
if (toPrint.equals("Player"))
return "Player" + playerNumber + ", it's your turn";
return toPrint;
}
} }
...@@ -348,4 +348,12 @@ public class Graphic extends Display { ...@@ -348,4 +348,12 @@ public class Graphic extends Display {
} }
return ints; return ints;
} }
@Override
public String printing(String toPrint, int playerNumber) {
b.setVisible(false);
b.setText(super.printing(toPrint, playerNumber));
b.setVisible(true);
return super.printing(toPrint, playerNumber);
}
} }
...@@ -3,6 +3,7 @@ package com.company; ...@@ -3,6 +3,7 @@ package com.company;
import java.util.Scanner; import java.util.Scanner;
import java.util.Timer;
public class Main { public class Main {
...@@ -30,22 +31,35 @@ public class Main { ...@@ -30,22 +31,35 @@ public class Main {
turns++; turns++;
if (turns %2 == 1){ if (turns %2 == 1){
if (play1.numberOfPlayerPossibleMoves(play2.getArr2(), play1.getArr1()) != 0) { if (play1.numberOfPlayerPossibleMoves(play2.getArr2(), play1.getArr1()) != 0) {
if () if (displayType == 0)
System.out.println("Player1, it's your turn!"); console.printing("Player", 1);
else
graphic.printing("Player", 1);
} }
else { else {
//if there is no possible move prints pass //if there is no possible move prints pass
System.out.println("pass"); if (displayType == 0)
console.printing("pass", 1);
else
graphic.printing("pass", 1);
turns++; turns++;
} }
} }
if (turns %2 == 0){ if (turns %2 == 0){
if (play2.numberOfPlayerPossibleMoves(play1.getArr1(), play2.getArr2()) != 0) { if (play2.numberOfPlayerPossibleMoves(play1.getArr1(), play2.getArr2()) != 0) {
//System.out.println("Player2, it's your turn!"); if (play1.numberOfPlayerPossibleMoves(play2.getArr2(), play1.getArr1()) != 0) {
if (displayType == 0)
console.printing("Player", 2);
else
graphic.printing("Player", 2);
}
} }
else { else {
//if there is no possible move prints pass //if there is no possible move prints pass
System.out.println("pass"); if (displayType == 0)
console.printing("pass", 2);
else
graphic.printing("pass", 2);
continue; continue;
} }
} }
......
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