Class CodeFactory

java.lang.Object
mastermind.core.CodeFactory

public class CodeFactory extends Object
Factory class for creating Code objects.
  • Method Details Link icon

    • fromColorIndices Link icon

      public static Code fromColorIndices(List<Integer> indices)
      Creates a Code object from a list of color indices.
      Parameters:
      indices - List of color indices.
      Returns:
      A Code object.
    • getRandom Link icon

      public static Code getRandom()
      Creates a random Code object.
      Returns:
      A random Code object.
    • getRandomFromFile Link icon

      public static Code getRandomFromFile(File file) throws FileNotFoundException
      Creates a random Code object from a file.
      Parameters:
      file - File containing the codes.
      Returns:
      A random Code object.
      Throws:
      FileNotFoundException - If the file is not found.
      IllegalArgumentException - If the file is empty, the code length is invalid, or the color index is invalid.