Class LadderBoardFactory

java.lang.Object
edu.ntnu.idi.idatt.factory.board.LadderBoardFactory
All Implemented Interfaces:
BoardFactory

public class LadderBoardFactory extends Object implements BoardFactory
Factory class for creating LadderGameBoard objects.

This class provides methods for creating LadderGameBoard objects based on predefined variants. LadderGameBoard objects can also be created from an external file.

  • Constructor Details

    • LadderBoardFactory

      public LadderBoardFactory()
  • Method Details

    • createBoard

      public Board createBoard(String variant)
      Creates a LadderGameBoard object based on predefined variants stored as json files in the "resources/boards" directory.
      Specified by:
      createBoard in interface BoardFactory
      Parameters:
      variant - A string specifying which board variant to create.
      Returns:
      A configured LadderGameBoard object.
      Throws:
      IllegalArgumentException - if the variant is not recognized.
    • createBoardFromFile

      public Board createBoardFromFile(String filePath)
      Creates a Board object by reading from an external file. File handling is delegated to the LadderGameBoardFileHandlerGson class.
      Specified by:
      createBoardFromFile in interface BoardFactory
      Parameters:
      filePath - The path to the JSON file containing board data.
      Returns:
      A Board object constructed from the file data.
      See Also:
    • createBlankBoard

      public Board createBlankBoard(int rows, int columns)
      Creates a blank LadderGameBoard object with the given number of rows and columns.
      Specified by:
      createBlankBoard in interface BoardFactory
      Parameters:
      rows - The number of rows in the board.
      columns - The number of columns in the board.
      Returns:
      A LadderGameBoard object with the given number of rows and columns, that has no tile actions.