Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Mar 28, 2016
2 parents 28a072a + 4391759 commit a9ed604
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

4 changes: 4 additions & 0 deletions src/model/Piece.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public void promote() {
public Type getType() {
return this.type;
}

public Color getColor() {
return this.color;
}
}
12 changes: 12 additions & 0 deletions src/model/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package model;

public class Test {
public static void main(String[]args)
{
Board checkers = new Board();
checkers.initBoard();
checkers.printBoard();
}


}

0 comments on commit a9ed604

Please sign in to comment.