Answered step by step
Verified Expert Solution
Link Copied!

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 1- 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 26 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 2- 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 try/catch 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 wordUsesPuzzleLettersOnly(String word)- returns true if word consists only of letters that are in the
puzzle.
boolean wordUsesCenterLetter(String 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 3- 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 four-letter word is worth
one point, but longer words score the number of letters they contain, so that a five-letter 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 wordIsPangram(String 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 8,2020) should
look appear as shown below. The word excellent ly, for example, scores 18 points: 11 for the number of letters in the
word and 7 for the pangram bonus. Note that the pangram appears in blue. Milestone 4- Let the user try to find the words (Extra CreHelp me finish the code as provided given the prompts/guidelines. 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.
image text in transcribed

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Evaluate the probabilities when n = 8 and p = .2 24. P(x2)

Answered: 1 week ago