Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make codes for this assignment in Java. They have something code in them, you just need to make a new code for each part

Please make codes for this assignment in Java. They have something code in them, you just need to make a new code for each part that it shows " // TODO: implement this ". They totally have 4 parts needed to do it. Thanks.

1.

public Wordle(String[] words) { // TODO: implement this }

2.

public void loadWords(String filenm, int length, long minfreq, long maxfreq) throws IOException { // TODO: implement this return; }

3.

public ArrayList getKnownWords() { // TODO: implement this return null; }

4.

public Hint(String guess, String secretWord) { // TODO: implement this }

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Playing a game of wordle can be broken down into these steps: 1. The computer obtains a list of possible words 2. The computer selects one word as the "secret" which the player will try to guess 3. The player guesses a word 4. The computer generates a hint about which letters are correct/incorrect. 5. The hint is communicated to the player. 6. Guessing continues until the player is out of turns or wins the game. The game is implemented in three classes: \%ordle, Hint, and Hordlegame. The Hordle class is responsible for items (1) and (2) above. Both the "ordle class and the Hint class are responsible for item (4). The Word1e class must be part of providing a hint to the player since the Hord1e class knows what the secret word is. However, the logic for how to construct the hint itself, and the data associated with the details of the hint are encapsulated by the Hint class, so the \%ord1e class acts mainly as a middle-man. The word1eGame class contains the logic for interacting between the computer and the player. That is, it is a user of the wordle and Hint classes. Specifically, the Hordegame starts steps (1) and (2) off by creating the word1e object instance. The wordleGame allows a player to guess a word (step 3) by reading input from the keyboard, and then sends that to the computer (i.e., the "ordle object instance) to obtain a hint, which is then printed for the user (step 5). This "game loop" continues until no more guesses remain, or the game is won (step 6). Implementation All coding takes place in the file lordle. java. You should look through all the code and generally l've tried to order the parts so that easier items are implemented first. Without a doubt, the most complex code live in the Hint constructor. Here, you'll be constructing a Hint to the puzzle. Of course constructing a Hint requires knowing what the secret word is as well as what the guess was. Then you'll need to figure out what letters are correctly placed, what letters are in the secret word, but incorrectly placed, and what letters aren't in the secret word at all. Read the comments for the constructor for more details. I suggest you implement this with a series of stages. First determining which characters are correctly placed then checking which are incorrectly placed, and finally determining which are not in the puzzle. Each stage will require some looping. Further there are a number of ways to create the Strings that will eventually become hint's instance variables. Here are some options: - Build Strings by concatenating smaller Strings with the + operator. - Build Strings from char arrays. - Build Strings using the StringBuilder class. At the top of the Hint constructor, you should provide a comment that provides reasoning/justification for the method you've used to build the Strings each Hint instance uses. You may use any of * Part 4: Implement this Constructor.- * Given a guess and the secret word, provide a hint. * The Hint should follow these guidelines: * - the Hint should not store any knowledge of the secret word itself. * - correctlyplaced should have a length equal to the length of the secret word * - incorrectlyplaced should have a length equal to the length of the secret word * - notinPuzzle should have a length less than or equal to the length of the secret word/guess. * A character in the guess that is both the correct letter, and in the correct location in the word * will appear in that location in the correctlyPlaced String. Characters in the guess that are not * correctly placed will appear as the char '-' in the correctlyPlaced string. * Thus, for a guess "skate" and a secret word "score", the correctlyplaced will be: "s--e" * A character in the guess that is the correct letter, but not in the correct location in the word * will appear in the same location as the guess when placed in the incorrectedplaced String. * Note that duplicate characters are a bit tricky, they must be examined for correctly placed characters * before incorrectly placed ones. * Thus, for a guess "scoop" and a secret word "poofs", the correctlyplaced String is: "--o-." and * incorrectlyPlaced String is: "s--op" * Note that the first ' 0 ' is correctly placed, thus it must be the second ' 0 ' that is incorrectly placed. * It is incorrect to say that the first 'o' is incorrectly placed, as it is incorrect to say that * both 'o's are incorrectly placed. * Characters that are in the guess and are neither correctly placed nor incorrectly placed should be * added to the notinpuzzle String. Thus, the length of the notinPuzzle string will never be greater * than the length of the secret word, or the guess. * Qparam guess * @param secretWord */ no usages public Hint(String guess, String secretWord) \{ // TODO: implement this \} nuhl ir hnnlaan iswin() f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions