Complete Code
Complete Code
Scanner;
import java.io.File;
import java.io.FileNotFoundException;
/** Play a version of the Wordle game. The data is stored in Wodle.txt in a
* word. This allows users to play the game repeatedly. Users then guess five
* told which letters and positions are correct in the word. Users get only
*/
of the computer
Scanner keyboard = new Scanner(System.in);
getWordFromFileMethod
// TODO Convert the word that is returned from the method call to lower
case
word = word.toLowerCase();
// Counting loop
// Let the user make MAX_GUESSES. Stop if they get all the characters
correct
//TODO Write a loop that lets the user make six guesses as to what the
hidden word is
while(count<MAX_GUESSES&&numberOfCha!= WORD_LENGTH) {
//TODO Let the user enter their guess and convert it to lower
case
letters");
guess = guess.toLowerCase();
count++;
numberOfCha = showResult(word,guess);
}//end loop
//TODO Let the user know what the hidden word was if they didn't guess
it
if(numberOfCha!= WORD_LENGTH) {
//Print out the number of guesses they took to get their answer (or
not).
/** Choose a word from the Wordle file. The word will be chosen by letting
* word number. This allows the user to play the game multiple times in the
same day.
constructed in the
* main program.
*/
FileNotFoundException
//TODO Let the user tell you which word number they want to play--think
keyboard.nextLine();
//TODO Skip number of lines in the file that the user entered--the
file.nextLine();
count++;
//TODO Skip over the stuff we don't need in the line of the file that
file.next();
file.nextInt();
file.nextInt();
file.next();
file.nextInt();
selectWord = file.next();
file.close();
/** Show the user how well their guess did by printing an * if the letter is
the right
* letter in the correct position, an ! if the letter is in the word but not
in the correct
* @return The number of characters that are in the correct position in the
guess.
*/
should be a loop
// chosenWord = chosenWord.toLowerCase();
// guess = guess.toLowerCase();
int count = 0;
int numberOfChar = 0;
if(guess.charAt(count)==chosenWord.charAt(count)) {
System.out.print(SUCCESS);
numberOfChar++;
System.out.print(RIGHT_LETTER_WRONG_PLACE);
else {
System.out.print(WRONG_LETTER);
}
count++;
System.out.println();
//TODO Return the number of letters that are in the correct place--this