Class LadderGameBoard

java.lang.Object
edu.ntnu.idi.idatt.model.board.BaseBoard
edu.ntnu.idi.idatt.model.board.LadderGameBoard
All Implemented Interfaces:
Board

public class LadderGameBoard extends BaseBoard
LadderGameBoard class

Concrete implementation of the Board interface for the Chutes and Ladders game. This class extends BaseBoard and implements game-specific board functionality.

See Also:
  • Field Details

    • rowsAndColumns

      protected int[] rowsAndColumns
    • background

      protected String background
    • pattern

      protected String pattern
  • Constructor Details

    • LadderGameBoard

      public LadderGameBoard(String name, String description, int[] rowsAndColumns, String background, String pattern)
      Constructor for LadderGameBoard.
      Parameters:
      name - The name of the board
      description - The description of the board
      rowsAndColumns - The number of rows and columns in the board
      background - The background of the board
      pattern - The pattern of the board
  • Method Details

    • getRowsAndColumns

      public int[] getRowsAndColumns()
      Gets the number of rows and columns in the board.
      Returns:
      an array containing [rows, columns]
    • getPattern

      public String getPattern()
      Gets the pattern of the board.
      Returns:
      the pattern of the board
    • setRowsAndColumns

      public void setRowsAndColumns(int[] rowsAndColumns)
      Sets the number of rows and columns in the board. Also creates the tiles for the board based on the rows and columns by calling the appropriate method.
      Parameters:
      rowsAndColumns - an array containing [rows, columns]
      See Also:
    • setPattern

      public void setPattern(String pattern)
      Sets the pattern of the board.
      Parameters:
      pattern - the pattern to set
    • getTileCount

      public int getTileCount()
      Gets the total number of tiles on the board excluding the starting tile, which normally is outside of the board, with the id 0.
      Specified by:
      getTileCount in interface Board
      Overrides:
      getTileCount in class BaseBoard
      Returns:
      the number of tiles
    • createTiles

      public void createTiles(int rows, int columns)
      Creates a list of Tile objects that are arranged in a grid pattern with alternating directions in each row. The first tile is in the lower left corner of the grid, and the direction of the first row is left to right. This is the standard way to create a board for the Chutes and Ladders game.

      If the board already contains tiles, and they have any tile actions, these will be added to the new tiles if they are within the new board dimensions.

      Parameters:
      rows - The number of rows in the grid
      columns - The number of columns in the grid