Commit 3422efaf authored by Haj Rezvan's avatar Haj Rezvan

Add Check for doesn't null map & visualMap elements

parent 6a106bd8
......@@ -5,6 +5,7 @@ import java.io.IOException;
* @author Rezvanian 9831029
* @version 0.0
*/
public class Board implements IBoard {
private final int SIZE = 9;
//for programmer
......@@ -16,6 +17,7 @@ public class Board implements IBoard {
* This constructor, initialise the fields.
*/
public Board(){
map = new char[81];
for (int i = 0; i < SIZE * SIZE; i++){
switch (i){
......@@ -71,7 +73,8 @@ public class Board implements IBoard {
this.map[i] = '8';
}
default:{
this.map[i] = ' ';
if (this.map[i] != 'w' || this.map[i] != 'b')
this.map[i] = ' ';
}
}
}
......@@ -84,7 +87,8 @@ public class Board implements IBoard {
}else if (yColumn % 8 == 0){
visualMap[xRow][yColumn] = '*';
} else {
visualMap[xRow][yColumn] = ' ';
if (this.visualMap[xRow][yColumn] != 'w' || this.visualMap[xRow][yColumn] != 'b')
visualMap[xRow][yColumn] = ' ';
}
}
for (int i = 0; i <= 36; i++){
......@@ -144,7 +148,7 @@ public class Board implements IBoard {
public void setVisualMapByPosition(int xPosition, int yPosition, char nut){
xPosition = 8 * (xPosition - 1) + 4;
yPosition = 4 * (yPosition - 1) + 2;
visualMap[yPosition][xPosition] = nut;
this.visualMap[yPosition][xPosition] = nut;
}
public int searchPosition(char c){
......
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