Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class View implements InterfaceView {
- public void displayBoard(Board board, Animal... animals) {
- String[][] plateau = new String[board.getNbrow()][board.getNbcolumn()];
- for (int i = 0; i < plateau.length; i++) {
- for (int j = 0; j < plateau[0].length; j++) {
- Position position = new Position(i, j);
- if (null == board.getSquare(position)) {
- plateau[i][j] = TerminalColor.BG_WHITE
- //+ " NULL "+
- + " "
- + TerminalColor.DEFAULT;
- } else {
- switch (board.getSquareType(position)) {
- case STAR:
- plateau[i][j] = TerminalColor.BG_RED_FG_WHITE
- //+ " STAR "
- + "| * |"
- + TerminalColor.DEFAULT;
- break;
- case GRASS:
- plateau[i][j] = TerminalColor.BG_GREEN_FG_WHITE
- //+ " GRASS "
- + "| |"
- + TerminalColor.DEFAULT;
- break;
- default:
- plateau[i][j] = TerminalColor.BG_BLUE
- //+ " NULL "+
- + " "
- + TerminalColor.DEFAULT;
- break;
- }
- }
- for (Animal pet : animals) {
- if (position.equals(pet.getPositionOnBoard())) {
- if (pet.getClass().getSimpleName().toString().equals("Spider")) {
- plateau[i][j] = TerminalColor.BG_GREEN_FG_WHITE // fg black
- + "m°°m"
- + TerminalColor.DEFAULT;
- } else if (pet.getClass().getSimpleName().toString().equals("Snail")) {
- plateau[i][j] = TerminalColor.RED
- + " Q "
- + TerminalColor.DEFAULT;
- }
- }
- }
- }
- System.out.println();
- }
- for (int x = 0; x < plateau.length; x++) {
- for (int y = 0; y < plateau[0].length; y++)
- System.out.print(plateau[x][y]);
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement