Program 1: Wordle

Due Date and Submission Requirements


The goal of this lab is:


Background and Directions

You will be writing a java program that simulates the game Wordle. If you are not familiar with Wordle, you should first spend some time trying it out, and familiarizing yourself with how the game is played. I will not be providing you with any starting code. You will need to build this solution from scratch.

The user has a certain number of tries to guess the word. They can play on easy mode, normal mode, or hard mode. On easy mode, they get 8 guesses. On normal mode, they get 6 guesses. On hard mode, they get 4 guesses. After each guess, the program will tell them if they are correct or incorrect. If they are incorrect, it should print out which letters are correct (green), incorrect (gray/red), and correct but in an incorrect spot (yellow). We cant really use colors in Java, so instead they will be represented by symbols/emojis.
✔️ is used to indicate the letter is in the correct spot.
❌ is used to indicate the letter is not in the word at all.
🟨 is used to indicate the letter is in the word, but in the wrong spot.

For example, if the word is "TRAIN" and the user guesses "TRIPS", the output should be ✔️✔️🟨❌❌. Some students have issues printing out emojis. These don't have to be emojis. You can use letters or a different set of symbols.

The words must be randomly selected from worlde_words.txt which will be in input file your program needs to read. This file has 60 words that have been used in Wordle puzzles in the past. Note: every single one of these words are of length 5, and do not contain duplicate letters (this makes the program a bit easier).

If the user correctly guesses the word, the program should print out how many guesses it took, and the program ends. After 6 guesses, the program should end, and the answer should be printed out. The user MUST enter a five length word as their guess. If they enter an invalid guess (eg. "AA" or "AAAAAAAAA"), then it should prompt the user to enter another guess until they give a valid word. Their guess does not need to be a valid english word, so "AAAAA" is a valid guess. The user should be able to enter their guess in lowercase, and the program should still work.

Assumptions

The input file will always have 60 words, of length five, with no duplicate letters in the word

The user will enter their guess in all uppercase, lowercase, or a mixture of both, and will not have any duplicate letters.

Input file

wordle_words.txt (make sure you drag and drop it into your program1 Java project folder)

Required Output

When you run your program, it should follow a similar output as seen here (obviously your word will probably be different).
Here is another sample output , where the user loses the game.
Here is another sample output , where the user tries to provide invalid inputs.

Optional Hints

You should at least have a Wordle and a WordleDemo class.

.charAt(x) is a method you call on a String that returns the character (a char) at index x

.indexOf(c) is a method you call on a String that returns the first occurance index of some char c (if it exists). If it does not exist, this method returns -1.

.equals() returns true if two Strings are the same.

Grading (100 points)

Criteria Points
words.txt is read in by the program 5
The user is able to play on easy mode, normal mode, or hard mode 5
A random word from the file is selected each time the game is played 10
After the correct number of incorrect guesses, the program ends and the answer is printed out 20
The program ends if the user guesses correctly, and prints out number of guesses made 10
The program correctly identifies green (checkmark) characters 10
The program correctly identifies yellow (box) characters 10
The program correctly identifies red (X) characters 10
If the user enters a guess  > or < 5 characters, it prompts the user to re-enter their guess 10
Your program contains an adequate amount of comments 10






Program 1 solution