Commit 9e532c5f authored by amir's avatar amir

adding graphic version

parent 13f1fbcc
package com.company; package com.company;
public class Console { public class Console extends Display {
public Console(byte displayType) {
super(displayType);
}
@Override
public void display(int[][] a1, int[][] a2) {
super.display(a1, a2);
System.out.println(" A B C D E F G H");
for (int i = 1; i <= 8; i++) {
for (int j = 1; j <= 8; j++) {
if (a2[j][i] != 0) {
// the unicode of white circle (there is a player2 disc)
System.out.print('\u25CB');
}
else {
if (a1[j][i] != 0) {
// the unicode of black circle (there is a player1 disc)
System.out.print('\u25CF');
}
else
// the unicode of white square (a blank)
System.out.print('\u25A1');
}
System.out.print(" ");
}
System.out.println();
}
}
} }
package com.company;
public class Display {
private byte displayType;
public Display(byte displayType){
this.displayType = displayType;
}
/**
* displays the place of black and white discs and blanks (will be overridden in console and graphic version)
* @param a1 array of the player1's discs
* @param a2 array of the player2's discs
*/
public void display(int[][] a1, int[][] a2){
}
}
This diff is collapsed.
...@@ -80,38 +80,7 @@ public class Players { ...@@ -80,38 +80,7 @@ public class Players {
} }
} }
/**
* displays the place of black and white discs and blanks
* @param a1 array of the player1's discs
* @param a2 array of the player2's discs
* @param displayType type of display
*/
public void display(int[][] a1, int[][] a2, byte displayType){
if (displayType == 0) {
System.out.println(" A B C D E F G H");
}
for (int i = 1; i <= 8; i++){
if (displayType == 0)
System.out.print(i+ " ");
for (int j = 1; j <= 8; j++) {
if (containsInArray(a2, j, i)) {
// the unicode of white circle (there is a player2 disc)
System.out.print('\u25CB');
}
else {
if (containsInArray(a1, j, i)) {
// the unicode of black circle (there is a player1 disc)
System.out.print('\u25CF');
}
else
// the unicode of white square (a blank)
System.out.print('\u25A1');
}
System.out.print(" ");
}
System.out.println();
}
}
/** /**
* this method checks if the move is possible, then equalize the color of the * this method checks if the move is possible, then equalize the color of the
......
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