Class WordGenerator

  • All Implemented Interfaces:
    Serializable, IClusterable

    public class WordGenerator
    extends Object
    implements IClusterable
    The word generator is responsible for reading in a list of words from a data file and serving them up in a random order. The generator keeps a state record of which words it has served and randomises them again when the last word has been served.
    Version:
    1.0
    Author:
    Chris Turner
    See Also:
    Serialized Form
    • Constructor Detail

      • WordGenerator

        public WordGenerator()
        Create the word generator, loading the words and preparing them for serving.
      • WordGenerator

        public WordGenerator​(String[] words)
        Create the word generator using the supplied array of words as the word source to use.
        Parameters:
        words - The words to use
    • Method Detail

      • next

        public Word next()
        Returns the next word from the word generator.
        Returns:
        The next word
      • size

        public int size()
        Get the number of words that were discovered.
        Returns:
        The number of words