diff --git a/src/model/Board.java b/src/model/Board.java index abbe466..d908c4d 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -60,6 +60,51 @@ public boolean hasAttackVector(Piece p) { can_attack |= checkAttackDirection(p, Direction.DOWN, Direction.RIGHT); } return can_attack; + } + + public void initBoard() + { + for(int row = 0; row < 3; row++){ + for (int col = 0; col < 4; col++) + { + representation[row][2*col+ (row % 2)] = new Piece(Color.RED, row, 2*col + (row % 2)); + representation[BOARD_SIZE - 1 - row][2*col + (BOARD_SIZE - 1 - row) %2] = new Piece(Color.BLACK, BOARD_SIZE - 1 - row, 2*col + (BOARD_SIZE - 1 - row) %2); + } + } + } + + public void printBoard() + { + for(int row = 0; row < BOARD_SIZE; row++) + { + for (int col = 0; col < BOARD_SIZE; col++) + { + if (!isOccupied(row, col)) + System.out.print("| "); + else if (representation[row][col].getColor() == Color.RED) + { + if (representation[row][col].getType() == Type.NORMAL) + System.out.print("|r"); + else + System.out.print("|R"); + } + else + { + if(representation[row][col].getType() == Type.NORMAL) + System.out.print("|b"); + else + System.out.print("|B"); + } + + } + System.out.println("|"); + } } + + public boolean isOccupied(int row, int col) + { + return representation[row][col] != null; + } + } diff --git a/src/model/Piece.java b/src/model/Piece.java index cce93ae..6eea5bc 100755 --- a/src/model/Piece.java +++ b/src/model/Piece.java @@ -39,4 +39,8 @@ public void promote() { public Type getType() { return this.type; } + + public Color getColor() { + return this.color; + } } diff --git a/src/model/Test.java b/src/model/Test.java new file mode 100644 index 0000000..668ff38 --- /dev/null +++ b/src/model/Test.java @@ -0,0 +1,12 @@ +package model; + +public class Test { + public static void main(String[]args) + { + Board checkers = new Board(); + checkers.initBoard(); + checkers.printBoard(); + } + + +}