Package outputProviders
Class IterationResult
java.lang.Object
outputProviders.IterationResult
Represents the result of an iteration in the application.
Contains information such as iteration number, map file type, map file path,
string sequence, error code, and output messages. Also check if the combination
of the map and the actions is valid.
-
Constructor Summary
ConstructorsConstructorDescriptionIterationResult(int iterationNumber, String mapFilePath, String stringSequence, int exitCode, String outputMessages, String customAttribute) Constructs an IterationResult object with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionextractSubstrings(String input) From a full action sequence, get the strings that actually are executed (Starting with the last S and ending with the first E, or Q if customSequencesNR= 10).Get the note of the program with this particular map file if applicable.intReturns the error code associated with the iteration.intReturns the number of the iteration.static char[][]Makes a map that stores each char at its x and y coordinate, from a .txt file that represents the map.Return the map file name without the path (as calculated in FileHandler).Returns the file path of the map.Returns the file type of the map, based on its suffix in the file path.Returns the output messages produced during the iteration.static int[]getPlayerLocation(char[][] map) Returns the coordinates of the player within the map.Returns the string sequence associated with the iteration.static booleanisValidMove(String mapFilePath, String actionSequence) Checks for each the action sequence if this is a possible move within the map: when the game has already started, and has not ended yet, the player does not move to a wall cell or outside the bounds of the map.
-
Constructor Details
-
IterationResult
public IterationResult(int iterationNumber, String mapFilePath, String stringSequence, int exitCode, String outputMessages, String customAttribute) Constructs an IterationResult object with the specified parameters. Replaces unknown exit codes with -1, and empty output-messages and custom attributes with "None".- Parameters:
iterationNumber- The number of the iteration.mapFilePath- The file path of the map.stringSequence- The string sequence associated with the iteration.exitCode- The error code associated with the iteration.outputMessages- The output messages produced during the iteration.customAttribute- The custom attribute of the map file (often some extra information) associated with the iteration.
-
-
Method Details
-
getIterationNumber
public int getIterationNumber()Returns the number of the iteration.- Returns:
- The iteration number.
-
getMapFilePath
Returns the file path of the map. Note that map files get moved to a particular subdirectory of actual_ after making them. This method returns the path of the map file in the correct actual maps subdirectory.- Returns:
- The map file path, cleaned up.
-
getMapFileName
Return the map file name without the path (as calculated in FileHandler).- Returns:
- The map file name with extension
-
getMapFileType
Returns the file type of the map, based on its suffix in the file path.- Returns:
- The map file type.
-
getStringSequence
Returns the string sequence associated with the iteration.- Returns:
- The string sequence.
-
getErrorCode
public int getErrorCode()Returns the error code associated with the iteration.- Returns:
- The error code.
-
getOutputMessages
Returns the output messages produced during the iteration.- Returns:
- The output messages.
-
getCustomAttribute
Get the note of the program with this particular map file if applicable.- Returns:
- String the custom map attribute
-
isValidMove
Checks for each the action sequence if this is a possible move within the map: when the game has already started, and has not ended yet, the player does not move to a wall cell or outside the bounds of the map.- Parameters:
mapFilePath- The file path of the .txt map fileactionSequence- The action sequence to be checked.- Returns:
- True if the actionSequence is true, false otherwise.
-
extractSubstrings
From a full action sequence, get the strings that actually are executed (Starting with the last S and ending with the first E, or Q if customSequencesNR= 10).- Parameters:
input- The full action sequence.- Returns:
- A list of strings that are executed.
-
getMap
Makes a map that stores each char at its x and y coordinate, from a .txt file that represents the map.- Parameters:
mapFilePath- The path to the .txt file that represents the map.- Returns:
- A 2D array of chars that represents the map.
-
getPlayerLocation
public static int[] getPlayerLocation(char[][] map) Returns the coordinates of the player within the map.- Parameters:
map- The map that stores each character and its x and y coordinates.- Returns:
- An int array of length 2, where the first element is the x coordinate, and the second element is the y coordinate.
-