Package mastermind.core
Class CodeFactory
java.lang.Object
mastermind.core.CodeFactory
Factory class for creating
Code
objects.-
Method Details
-
fromColorIndices
Creates aCode
object from a list of color indices.- Parameters:
indices
- List of color indices.- Returns:
- A
Code
object.
-
getRandom
Creates a randomCode
object.- Returns:
- A random
Code
object.
-
getRandomFromFile
Creates a randomCode
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.
-