Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Java for this project! (Part1-Part4) Playing a game of wordle can be broken down into these steps: 1. The computer obtains a list of

Use Java for this project! (Part1-Part4)

image text in transcribedimage text in transcribedimage text in transcribed

image 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

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions