Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Milestone 1 - Initialize the beehive with the letters in the puzzle field The first milestone requires you to update the puzzleAction method so that
Milestone Initialize the beehive with the letters in the puzzle field
The first milestone requires you to update the puzzleAction method so that typing seven letters into the Puzzle field
and hitting
updates the letters in the beehive on the screen after first checking to see that the letters represent
a legal puzzle, which must meet the following conditions:
The puzzle must contain exactly seven characters.
Every character must be one of the letters.
No letter may appear more than once in the puzzle.
If the string of characters entered by the user meets these criteria, your implementation of puzz leAction should call the
setBeehiveLetters method so that the letters appear on the screen. If not, your code should call showMessage with a
message telling the user why the puzzle is not properly formed see below
To do this, you will use a custom exception. Create the SpellingBeePuzzle class and the
SpellingBeePuzzleException class. Create the SpellingBeePuzzleException as we have done for custom
exceptions in class and described in the textbook. In the SpellingBeePuzzle class, start by implementing only the
constructor you can implement the other methods later The constructor should throw an instance of
SpellingBeePuzzleException if the provided puzzle fails to meet any one of the above three criteria. Include in the
thrown exception object an appropriate message that can be displayed to the user. In the puzzleAction method in
SpellingBee try to create an instance of SpellingBeePuzz le If an exception is thrown, catch the exception and
display the message provided in the exception object using showMessage. Otherwise, store a reference to the
SpellingBeePuzzle within the puzzle field, and call setBeehiveLetters to make the letters appear on the screen.
Milestone Display the legal words in the SpellingBee puzzle
The second milestone represents most of the work necessary for solving the Spelling Bee puzzle.
Start by adding code to the run method to load all of the words from the EnglishWords. txt data file into the ArrayList
named dictionary instance variable Don't forget to create the ArrayList object first. Use a trycatch block to handle
the IOException rather than adding throws IOException to the method header. If an exception occurs, display an
error message to the terminal, and return from the method.
Then, implement the solveAction method so that it goes through the dictionary and checks each word to see whether
it appears in the puzzle if you follow all the legal rules described above. Since you are iterating through dictionary
words, the only conditions you have left to check are the following:
The word is at least four letters long.
The word does not contain any letters other than the seven letters in the puzzle.
The word contains the center letter, which appears at the start of the puzzle string. To check the last two rules, implement the related methods in SpellingBeePuzzle and call them from the puzzle
object.
boolean wordUsesPuzzleLettersOnlyString word returns true if word consists only of letters that are in the
puzzle.
boolean wordUsesCenterLetterString word returns true if word contains the center letter for this puzzle the
first letter in the puzzle string
The first rule is straightforward to check by testing the length of the word.
Each time you find a word that fits these rules, you need to call the addWord method via the SpellingBeeGraphics
object to ensure that it appears on the screen.
Milestone Add scores to the display
For this milestone, your job is to extend the implementation of solveAction so that the scores displayed on the screen
are followed by the score for that word in parentheses. In the online version of SpellingBee, a fourletter word is worth
one point, but longer words score the number of letters they contain, so that a fiveletter word is worth five points, a six
letter word is worth six points, and so on Pangrams that use all seven letters in the puzzle score a bonus of seven
points.
To check that the word is a pangram, implement the isPangram method in SpellingBeePuzzle and call it when needed.
boolean wordIsPangramString word returns true if word is a pangram for this puzzle.
Your code should also keep track of the number of words found and the total score and then displayed using the
showMessage method. For example, the output for the puzzle "LYCENTX" which appeared on January should
look appear as shown below. The word excellent ly for example, scores points: for the number of letters in the
word and for the pangram bonus. Note that the pangram appears in blue. Milestone Let the user try to find the words Extra CreHelp me finish the code as provided given the promptsguidelines Make sure to call on the EnglishWord.txt file, SpellingBeeEventListener.java This file defines an interface that is used to specify event callbacks in the SpellingBee project and SpellingBeeGraphics.java where appropriate.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started