Class IterationResult

java.lang.Object
outputProviders.IterationResult

public class IterationResult extends Object
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

    Constructors
    Constructor
    Description
    IterationResult(int iterationNumber, String mapFilePath, String stringSequence, int exitCode, String outputMessages, String customAttribute)
    Constructs an IterationResult object with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    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.
    int
    Returns the error code associated with the iteration.
    int
    Returns the number of the iteration.
    static char[][]
    getMap (String mapFilePath)
    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 boolean
    isValidMove (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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public String 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

      public String getMapFileName()
      Return the map file name without the path (as calculated in FileHandler).
      Returns:
      The map file name with extension
    • getMapFileType

      public String getMapFileType()
      Returns the file type of the map, based on its suffix in the file path.
      Returns:
      The map file type.
    • getStringSequence

      public String 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

      public String getOutputMessages()
      Returns the output messages produced during the iteration.
      Returns:
      The output messages.
    • getCustomAttribute

      public String getCustomAttribute()
      Get the note of the program with this particular map file if applicable.
      Returns:
      String the custom map attribute
    • isValidMove

      public static boolean isValidMove (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.
      Parameters:
      mapFilePath - The file path of the .txt map file
      actionSequence - The action sequence to be checked.
      Returns:
      True if the actionSequence is true, false otherwise.
    • extractSubstrings

      public static List<String> extractSubstrings (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).
      Parameters:
      input - The full action sequence.
      Returns:
      A list of strings that are executed.
    • getMap

      public static char[][] getMap (String mapFilePath)
      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.