Package edu.ntnu.idi.idatt.model.board
Class LadderGameBoard
java.lang.Object
edu.ntnu.idi.idatt.model.board.BaseBoard
edu.ntnu.idi.idatt.model.board.LadderGameBoard
- All Implemented Interfaces:
Board
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 Summary
FieldsFields inherited from class edu.ntnu.idi.idatt.model.board.BaseBoard
description, name, tiles
-
Constructor Summary
ConstructorsConstructorDescriptionLadderGameBoard
(String name, String description, int[] rowsAndColumns, String background, String pattern) Constructor for LadderGameBoard. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createTiles
(int rows, int columns) Creates a list of Tile objects that are arranged in a grid pattern with alternating directions in each row.Gets the pattern of the board.int[]
Gets the number of rows and columns in the board.int
Gets the total number of tiles on the board excluding the starting tile, which normally is outside of the board, with the id 0.void
setPattern
(String pattern) Sets the pattern of the board.void
setRowsAndColumns
(int[] rowsAndColumns) Sets the number of rows and columns in the board.Methods inherited from class edu.ntnu.idi.idatt.model.board.BaseBoard
addTile, getBackground, getDescription, getName, getTile, getTiles, setBackground, setDescription, setName
-
Field Details
-
rowsAndColumns
protected int[] rowsAndColumns -
background
-
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 boarddescription
- The description of the boardrowsAndColumns
- The number of rows and columns in the boardbackground
- The background of the boardpattern
- 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
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
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 interfaceBoard
- Overrides:
getTileCount
in classBaseBoard
- 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 gridcolumns
- The number of columns in the grid
-