-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.java
65 lines (56 loc) · 1.7 KB
/
Board.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.company;
public class Board {
private final Square[][] board;
private String piece;
int dims;
public Board(int dims) {
this.dims = dims;
board = new Square[dims][dims];
for (int x = 0; x < this.getDims(); x++) {
for (int y = 0; y < this.getDims(); y++) {
board[x][y] = new Square(this, false, x, y);
}
}
}
public Square getSquare(int x, int y){
return board[x][y];
}
public Square[][] getSquareArray() {
return this.board;
}
public int getDims(){
return this.dims;
}
public void printBoard(){
for (int y = 0; y < this.getDims(); y++) {
for (int x = 0; x < this.getDims(); x++) {
if(board[x][y].getOccupyingPiece() == null){
if(board[x][y].isVisited()) {
System.out.print("1 ");
}else{
System.out.print("0 ");
}
}else{
if(board[x][y].getOccupyingPiece().toString() == "King") {
System.out.print("K ");
}
if(board[x][y].getOccupyingPiece().toString() == "Knight") {
System.out.print("Kn");
}
}
}
System.out.println();
}
System.out.println();
}
public boolean covered(){
for (int y = 0; y < this.getDims(); y++) {
for (int x = 0; x < this.getDims(); x++) {
if(!board[x][y].isVisited()){
return false;
}
}
}
return true;
}
}