Question: Need help finishing a Java Word Game program with provided skeleton code below. More methods can and should be added as necessary. Please help, and

Need help finishing a Java Word Game program with provided skeleton code below. More methods can and should be added as necessary. Please help, and make sure to just add to the code already provided!

// Prototype for a Code Word game in CS1

import java.util.Scanner;

public class CodeWord { public static final int WORDLENGTH = 5; public static final int DICTIONARYSIZE = 8548; // Holds all words public static String[] dictionary = new String[DICTIONARYSIZE]; // Indicates whether words can logically be ruled out public static boolean[] inPlay = new boolean[DICTIONARYSIZE];

public static void main(String[] args){ readDictionary(); // reads in dictionary Scanner console = new Scanner(System.in); while (yesTo("Do you want to play Code Word?", console)){ // play the game... // Since there is nothing in here yet, it will repeatedly // prompt Do you want to play Code Word? // An entire game should happen here, but // write separate methods whenever appropriate // for a task. } }

// more methods here -- a few headers have been provided // you will need to fill in some of them // and add more /** * reads the dictionary from the file into the dictionary array */ public static void readDictionary(){ // TODO }

/** * Compare the feedback from comparing a guess to the codeword to the feedback from * comparing the guess to each dictionary word, and filter out all dictionary words * with differing feedback. * * @param guess A user guess from the console * @param feedback String of *'s and +'s resulting from comparing the guess to the codeword */ public static void removeWordsWithDifferentFeedback(String guess, String feedback) { // TODO }

/** * This method takes two 5-letter words and returns a String * of asterisks containing the feedback that the user would get * for comparing word1 to word2. Recall that the number of asterisks (*'s) * equals the number of in-place matches, and the number of plus signs (+'s) * equals the number of out-of-place matches. All asterisks should * precede all plus signs. * * @param word1 5-letter word, e.g. a user guess * @param word2 Another 5-letter word, e.g. the secret code word * @return Feedback of asterisks and plus signs indicating the number * of in- and out-of-place matches. */ public static String feedback(String word1, String word2) { return ""; //TODO } /** * Utility function to ask user yes or no. * No modifications are necessary for this method. * It uses a forever loop -- but the loop stops when something is returned. * @param prompt Text presented to user * @param console Source of user input * @return Whether user types 'y' (as opposed to 'n'). */ public static boolean yesTo(String prompt, Scanner console) { for (;;) { System.out.print(prompt + " (y)? "); String response = console.next().trim().toLowerCase(); if (response.equals("y")) return true; else if (response.equals("n")) return false; else System.out.println("Please answer y or n."); } } }

The requirements of the game are this:

Need help finishing a Java Word Game program with provided skeleton codebelow. More methods can and should be added as necessary. Please help,

and make sure to just add to the code already provided! //

and the ending output of the game should look like this:

Prototype for a Code Word game in CS1 import java.util.Scanner; public class

Requirements: In summary, your program must do the following things: The game must read in the dictionary from the provided file, wordList.txt, (which contains only five-letter words), and store it in the provided dictionary array. You should also indicate that all words are in play using the provided inPlay array. You may not alter the file name. I will use a copy of the original file when I test/grade your code The program will ask the user to play the game. An answer of 'y' starts a new game, and an answer of 'n' exits the program. The proqgram asks the user to play the game again after each complete game (win or lose). Be sure to reset the words that are in play when a new code word is chosen If the user chooses to play a game, then the program asks the user how many guesses to grant before the game ends. Be sure to perform error checking on this and all other user inputs. Then the user gets to guess one five-letter string at a time and get feedback in accordance with the game rules above. After each incorrect guess, the program outputs the complete list of previous guesses combined with the feedback regarding in- and out-of-place matches. If the user enters anything besides a lowercase five-letter string, or if the string contains strange characters (like numbers, punctuation, etc.), then instead of counting this as a guess, the program should give an error message and ask the user to enter their guess again. The guesses do not need to be actual words in the dictionary, but they do need to be strings consisting only of lowercase letters. The one exception to the above rule is that the the user always has the option of typing r' (stands for "remaining words") to get a list of words that have not yet been ruled out by the behind-the-scenes filtering hint system

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!