Divide the total points scored by the number of words presented.
Write an application called Scramble that has a GUI to play a game of word anagrams. Create two arrays of strings. The first array will hold words, and the second will hold scrambled versions of those words. Your Java code can initialize these arrays directly with the words. Display the scrambled version of the word in a label. The user will enter a guess for the word in a text field and press a Check button, You should see whether the guess is correct. If it is not correct, change the guess in the text field to Sorry, that is incorrect. Please try again. If the guess is correct, change it to “That is correct. Here is a new word to try.” And display a new scramble. Also provide a Give Up button. If it is pressed, display the unscrambled word and provide a new scrambled word.
Here are some extensions that can be made to improve this application:
• Read the words from a file.
• Do not use a second array of scrambled words, but instead use Java’s random number generator to swap letters in the word just before you display the scrambled word.
• Randomly decide which word to display.
• Keep a score. Award 5 points if the user gets the word on the first guess, 3 points for getting it on the second guess, or 1 point for getting it on the third guess.
This application keeps the possible words in an array and sets it directly within the code. It also has a couple private variables to remember the word it is on and the number of guesses made. It has a method to scramble the word. There are a number of different ways the scrambling could be done. This implementation repeatedly removes a random character from the word and adds that character to a result string.
See the code in Scramble.java.
You might also like to view...
Business computers are typically personalized to meet individual needs
Indicate whether the statement is true or false
Which of the following is correct when describing how a VMM or hypervisor works? (Choose all that apply.)
a. Configures all VMs with identical settings b. Provides customized settings for each VM c. Enables different types of operating systems to run on the same hardware d. Reproduces hardware and operating system