This question involves the WordMatch class, which stores a secret string and provides methods that compare other strings to the secret string. You will write two methods in the WordMatch class.
Write the WordMatch method scoreGuess. To determine the score to be returned, scoreGuess finds the number of times that guess occurs as a substring of secret and then multiplies that number by the square of the length of guess. Occurrences of guess may overlap within secret.
Assume that the length of guess is less than or equal to the length of secret and that guess is not an empty string.
The following examples show declarations of a WordMatch object. The tables show the outcomes of some possible calls to the scoreGuess method.
WordMatch game = new WordMatch("mississippi");
WordMatch game = new WordMatch("aaaabb");
Write the WordMatch method findBetterGuess, which returns the better guess of its two String parameters, guess1 and guess2. If the scoreGuess method returns different values for guess1 and guess2, then the guess with the higher score is returned. If the scoreGuess method returns the same value for guess1 and guess2, then the alphabetically greater guess is returned.
The following example shows a declaration of a WordMatch object and the outcomes of some possible calls to the scoreGuess and findBetterGuess methods.
WordMatch game = new WordMatch(“concatenation”);
Write the complete WordMatch class, including the constructor and any required instance variables and methods. Your implementation must pass all of the tests in the WordMatchTest class (provided).