Question: Here is my code for making a game called Wordle. I put the code at the auto lab, and the lab showed there are 3

Here is my code for making a game called Wordle. I put the code at the auto lab, and the lab showed there are 3 issues with it. Can you fix it, and show me the correct code?

The code:

import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Locale; import java.util.Random; import java.util.Scanner; public class Wordle { private ArrayList knownWords; private String secretWord; private Random rnd = new Random(); // a source of random numbers public Wordle(String file, int length, long minfreq, long maxfreq) throws IOException { // ~12K 5 letter words with min frequency of 100,000 knownWords = new ArrayList(); loadWords(file, length, minfreq, maxfreq); rnd = new Random(); initGame(); } public Wordle(String[] words) { knownWords = new ArrayList(); int wordLength = -1; for (String word : words) { if (!word.matches("^[a-zA-Z]+$")) { throw new IllegalArgumentException("All words must contain only letters!"); } if (wordLength == -1) { wordLength = word.length(); } else if (word.length() != wordLength) { throw new IllegalArgumentException("All words must be the same length!"); } knownWords.add(word.toLowerCase(Locale.ENGLISH)); // lowercase the word before adding it to the list } rnd = new Random(); initGame(); } public int numberOfKnownWords() { return knownWords.size(); } public void loadWords(String filenm, int length, long minfreq, long maxfreq) throws IOException { Scanner scan = new Scanner(new File(filenm)); while (scan.hasNext()) { String word = scan.next().toLowerCase(); // lowercase the word long freq = scan.nextLong(); if (word.length() == length && freq >= minfreq && (maxfreq == 0 || freq  getKnownWords() { return new ArrayList(knownWords); } public void initGame() { secretWord = knownWords.get(rnd.nextInt(knownWords.size())); } public Hint guess(String g) { if (g.length() != secretWord.length()) { throw new IllegalArgumentException("Wrong length guess!"); } return new Hint(g, secretWord); } } class Hint { private String correctlyPlaced; private String incorrectlyPlaced; private String notInPuzzle; private String guess; public Hint(String guess, String secretWord) { correctlyPlaced = "-".repeat(secretWord.length()); incorrectlyPlaced = "-".repeat(secretWord.length()); notInPuzzle = ""; this.guess = guess.toLowerCase(Locale.ENGLISH);; for (int i = 0; i  

These are the auto lab show issues:

Here is my code for making a game called Wordle. I put

setupGameFromSmallFile hintForSecretWordElite3 hintForSecretWordElite4 ( ) hintForSecretWordElite5 Hint: Check incorrectlyPlaced! expected: but was: setupGameFromArray2 (1) hintForSecretWordRaster1 Hint: Check incorrectlyPlaced! (- setupGameFromArray3 Hint: All words must be the same length

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!