-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleBoardDisplay.java
More file actions
32 lines (28 loc) · 909 Bytes
/
Copy pathSimpleBoardDisplay.java
File metadata and controls
32 lines (28 loc) · 909 Bytes
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
/**
* SimpleBoardDisplay is a concrete class holding board rendering logic without
* any colored text or background
*/
public class SimpleBoardDisplay implements BoardDisplay {
/**
* display method hold the logic for board rendering
*/
@Override
public void display(Board board) {
int rows = board.getRows();
int columns = board.getCoulmns();
Token[][] boardData = board.getBoard();
for (int i = 0; i < rows; i++) {
System.out.print((rows - i) + " ");
System.out.print("|");
for (int j = 0; j < columns; j++) {
System.out.print(" " + boardData[i][j] + " |");
}
System.out.println("");
}
System.out.print(" ");
for (int i = 0; i < columns; i++) {
System.out.print(" " + (i + 1) + " ");
}
System.out.println();
}
}