ConnectFourGame.java 1004 B

123456789101112131415161718192021222324252627282930313233
  1. public class ConnectFourGame implements Cloneable {
  2. public static final int BOARD_HEIGHT = 6;
  3. public static final int BOARD_WIDTH = 7;
  4. public static final int WINNING_NR = 4;
  5. private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT];
  6. private Color lastMove;
  7. private Color winner;
  8. private boolean isFinished = false;
  9. //[...]
  10. public void printBoard() {
  11. for (byte y = BOARD_HEIGHT - 1; y >= 0; y--) {
  12. System.out.print(y + " ");
  13. for (byte x = 0; x < BOARD_WIDTH; x++) {
  14. if (board[x][y] == null) {
  15. System.out.print(" ");
  16. } else if (board[x][y] == Color.RED) {
  17. System.out.print("r");
  18. } else {
  19. System.out.print("w");
  20. }
  21. }
  22. System.out.println("");
  23. }
  24. System.out.print(" ");
  25. for (byte x = 0; x < BOARD_WIDTH; x++) {
  26. System.out.print(x);
  27. }
  28. }
  29. }