Package edu.ntnu.idi.idatt.factory.board
Class LadderBoardFactory
java.lang.Object
edu.ntnu.idi.idatt.factory.board.LadderBoardFactory
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateBlankBoard
(int rows, int columns) Creates a blank LadderGameBoard object with the given number of rows and columns.createBoard
(String variant) Creates a LadderGameBoard object based on predefined variants stored as json files in the "resources/boards" directory.createBoardFromFile
(String filePath) Creates a Board object by reading from an external file.
-
Constructor Details
-
LadderBoardFactory
public LadderBoardFactory()
-
-
Method Details
-
createBoard
Creates a LadderGameBoard object based on predefined variants stored as json files in the "resources/boards" directory.- Specified by:
createBoard
in interfaceBoardFactory
- Parameters:
variant
- A string specifying which board variant to create.- Returns:
- A configured LadderGameBoard object.
- Throws:
IllegalArgumentException
- if the variant is not recognized.
-
createBoardFromFile
Creates a Board object by reading from an external file. File handling is delegated to theLadderGameBoardFileHandlerGson
class.- Specified by:
createBoardFromFile
in interfaceBoardFactory
- Parameters:
filePath
- The path to the JSON file containing board data.- Returns:
- A Board object constructed from the file data.
- See Also:
-
createBlankBoard
Creates a blank LadderGameBoard object with the given number of rows and columns.- Specified by:
createBlankBoard
in interfaceBoardFactory
- 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.
-