Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public RandomChooser(int wordLength, String dictionaryFile) The constructor takes two arguments: The desired word length A filename containing the dictionary to select a word from, with
public RandomChooser(int wordLength, String dictionaryFile) The constructor takes two arguments: The desired word length A filename containing the dictionary to select a word from, with one word on each line. You should throw an is less than one. You should throw an if there are no words found of You should randomly select a word from the provided dictionary that is characters long to be the secret word. You will likely want to store the chosen word as a field. You must use StdRandom from algs 4 ! This is so that we can test your code by controlling the randomness. Your code to select a random word should look more or less the same as this. Note that you'll need to assign the result of the call to a variable, i.e. int numWords = words size() int randomlyChosenWordNumber = StdRandom. uniform(numWords); words. get (randomlyChosenWordNumber); Here, should be a list of words of the desired length in sorted order, i.e. the output of calling from in This method should return the number of occurrences of the guessed letter in the secret word. You may assume all guesses passed are valid, i.e. they are lowercase letters and have not been guessed before. You should also update your public String getPattern() This method should return the current pattern to be displayed for the game using the guesses that have been made. Letters that have not yet been guessed should be displayed as a dash ( ). There should be no leading or trailing spaces. public String getword() This method should return the secret word being considered by the [Q Task: Implement the methods in as described above. Also, be sure to take a look at the code in | for some helper methods that might help you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started