Package Helper

Class Board


  • public class Board
    extends java.lang.Object
    Represents the game board for the Domineering game.
    Since:
    2023-12-01
    Version:
    1.0
    Author:
    Laamiri Ouail & Hajar Sadik
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String[][] board
      The 2D array representing the game board.
    • Constructor Summary

      Constructors 
      Constructor Description
      Board()
      Default constructor that initializes the board from the Configuration buttons.
      Board​(java.lang.String[][] board)
      Constructs a Board object with the given 2D array.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String[][] generateBoard​(java.lang.String[][] lastBoard, int x, int y, int player)
      Generates a new game board based on the last board state, move coordinates, and player.
      java.lang.String[][] getBoard()
      Gets the current game board.
      void setBoard​(java.lang.String[][] board)
      Sets the game board with the given 2D array.
      void setBoardFromButtons()
      Sets the game board from the Configuration buttons.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • board

        public java.lang.String[][] board
        The 2D array representing the game board.
    • Constructor Detail

      • Board

        public Board​(java.lang.String[][] board)
        Constructs a Board object with the given 2D array.
        Parameters:
        board - The 2D array representing the game board.
      • Board

        public Board()
        Default constructor that initializes the board from the Configuration buttons.
    • Method Detail

      • setBoard

        public void setBoard​(java.lang.String[][] board)
        Sets the game board with the given 2D array.
        Parameters:
        board - The 2D array representing the game board.
      • setBoardFromButtons

        public void setBoardFromButtons()
        Sets the game board from the Configuration buttons.
      • generateBoard

        public static java.lang.String[][] generateBoard​(java.lang.String[][] lastBoard,
                                                         int x,
                                                         int y,
                                                         int player)
        Generates a new game board based on the last board state, move coordinates, and player.
        Parameters:
        lastBoard - The last state of the game board.
        x - The x-coordinate of the move.
        y - The y-coordinate of the move.
        player - The player making the move.
        Returns:
        The new game board after the move.
      • getBoard

        public java.lang.String[][] getBoard()
        Gets the current game board.
        Returns:
        The 2D array representing the game board.