Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please design code for this assignment in Java. They have some code in them, you just need to make new code for each part that

Please design code for this assignment in Java. They have some code in them, you just need to make new code for each part that shows " // TODO: implement this ". There are 4 parts that is needed to do it. Thanks.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

* Part 2: Implement this method.- * Load words from a file. Each line of the file contains a ward followed by one or more spaces followed * by a number whose value is higher for words that are more 'frequently occurring' than others. * Loaded words should have a frequency value in the range [minfreg, maxfreg]. However, at times, these * Limits should be ignored (see comments below). Note that the words in the file may be many lengths * (e.g., 3-10 characters). Onzy words of the specified length should be loaded. * Hint: use a Scanner instance to read in the file and look for the next string or Long value. * the following pattern will be useful i) * Scanner scan = new Scanner( new File (filenm)); * The line above creates a Scanner from a File with the filename stored in the variable filenm * Use the scanner's . hasNext() method to test if there are more lines to read. * Use the scanner's . next() method to grab the next String token (word). * The scanner's . nextlong() method wilz grab the next token as a number (use this to read the frequency). * For each line, you will want to call scan.next() and scan. nextlong() to read the data * identifying a ward and its relative frequency. * Words of the specified length should be added into the knownWords list if their frequencies * are the in the range specified. * Hint: somewhere around 10-20 lines is probably appropriate here unless you have a lot of comments * aparam filenm - the file name to load from * Qparam length - the length of words we want to load (e.g., 5 to load 5 character words) * aparam minfreg - the minimum allowable frequency for a loaded word * Qaparam maxfreg - the maximum allawable freguenct for a loaded word; indicates no maximum 1 usage: public void LoadWords(String filenm, int length, Long minfreg, Long maxfreg) throws I0Exception \{ // TODO: implement this return; /** * _Part 3: Implement this method.- * * Obtain a list of known words. This method creates a new copy of the known words list. * Here, you simply need to copy the knownords list and return that copy. * * Qreturn a new copy of list of known words. */ no usages public Arraylist getKnownWords() \{ \} I/ TOD0: implement this 1+4 * 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. * - conrectlyplaced 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 hove a length less than or equal to the length of the secret word/guess. * A character in the guess that is bath the correct letter, and in the correct location in the word * Wilz appear in that location in the correctlyplaced String. Characters in the guess that are not * correctly placed will appear as the chap: I. 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 seeret word "poafs", the corpectlyplaced string is: "zo-." and * incorrectlypzaced String is: "s--op" * Note that the first ' 0 ' is correctly placed, thus it must be the second 'o' that is incorrectly placed. * It is incorrect to say that the first 'o' is incorrectzy placed, as it is incorrect to say that * both 'o's are incorrectly placed. * Characters that are in the guess and are neither carrectly placed nop incorpectly placed should be * added to the notinPuzzle String. Thus, the length af the notinPuzzle String will never be greater * than the length of the secret word, or the guess. * * Gparam guess 1 usage public Hint(String guess, String secretWord) \{ // TODO: implement this \}

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago