chooseWord method (20 points) This method randomly chooses a word. The method should read in words...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
chooseWord method (20 points) This method randomly chooses a word. The method should read in words from a file (such as words.txt, provided) and randomly choose a word. The method should also provide code to account for a missing file. In this case, the outcomeText should display an error message (such as "Error: No dictionary."). The guessField should then be disabled because the game cannot be played. The program should not crash or throw other exceptions. Hint for testing: Print out the randomly selected word you are trying to guess. This makes for much easier testing! handleGuessField method (50 points) This method responds to the user guess (typed into the guessField). This is basically the method that makes the game run! In this method, you should read in the user's guess and check if it is valid. If it's not valid, update the displays. If the guess is valid, you should check if the user has guessed the letter already. If they have, update the displays. If it's a new guess, check if it is right or wrong and update the displays. Then also check if the game is over (either the user guessed the word and won or reached the maximum wrong guesses and lost). For full credit: add additional helper methods. Do not have the entire game logic in the handleGuessField method. Some examples of helpful methods might be isGuessValid, updateDisplays, getDisplayVersion OfSWord, etc. create whatever instance data variables you need to keep track of things. Some examples might be a list that keeps track of guessed characters, an array that keeps track of whether each character in the word has been guessed, the number of wrong guesses, etc. reduce duplicated code You can add code to the start() method to initialize variables and/or invoke helper methods. I strongly recommend getting the game working before moving on to Part II. I strongly recommend getting the game working before moving on to Part II. Part II: Exception Handling (30 points) Add exception handling to cover three erroneous occurrences. Note: I realize you could write a working game that accounts for these situations without using exception handling. But, for this project, you are required to use exception handling. For all three situations, create your own exception type(s) to represent the situation. When the situation occurs, throw an object of the type you just created. The program should catch the exception(s) and update the displays. . The user continues to guess after invalid guesses. Invalid guesses does not count against the user's wrong guess count. Erroneous situations: 1. The user enters an empty guess 2. The user enters a guess that is longer than one character (like aa or zb) 3. The user enters a guess that is not a letter (like + or $) Hint: check out the Character class for help with detecting this situation! Your program method should not terminate or crash because of any of these thrown exceptions. All thrown exceptions should be caught and handled and the game should continue. Extra Credit: 15 points Allow the user to play multiple games. Add a "play again" button that is only visible when the game is over. Choose a new random word for each game. Sample Program and Project Files Below is a sample program you can run. For this program, the game only chooses between three words, to make it easier for you to guess! The words are apple, banana, and pear. chooseWord method (20 points) This method randomly chooses a word. The method should read in words from a file (such as words.txt, provided) and randomly choose a word. The method should also provide code to account for a missing file. In this case, the outcomeText should display an error message (such as "Error: No dictionary."). The guessField should then be disabled because the game cannot be played. The program should not crash or throw other exceptions. Hint for testing: Print out the randomly selected word you are trying to guess. This makes for much easier testing! handleGuessField method (50 points) This method responds to the user guess (typed into the guessField). This is basically the method that makes the game run! In this method, you should read in the user's guess and check if it is valid. If it's not valid, update the displays. If the guess is valid, you should check if the user has guessed the letter already. If they have, update the displays. If it's a new guess, check if it is right or wrong and update the displays. Then also check if the game is over (either the user guessed the word and won or reached the maximum wrong guesses and lost). For full credit: add additional helper methods. Do not have the entire game logic in the handleGuessField method. Some examples of helpful methods might be isGuessValid, updateDisplays, getDisplayVersion OfSWord, etc. create whatever instance data variables you need to keep track of things. Some examples might be a list that keeps track of guessed characters, an array that keeps track of whether each character in the word has been guessed, the number of wrong guesses, etc. reduce duplicated code You can add code to the start() method to initialize variables and/or invoke helper methods. I strongly recommend getting the game working before moving on to Part II. chooseWord method (20 points) This method randomly chooses a word. The method should read in words from a file (such as words.txt, provided) and randomly choose a word. The method should also provide code to account for a missing file. In this case, the outcomeText should display an error message (such as "Error: No dictionary."). The guessField should then be disabled because the game cannot be played. The program should not crash or throw other exceptions. Hint for testing: Print out the randomly selected word you are trying to guess. This makes for much easier testing! handleGuessField method (50 points) This method responds to the user guess (typed into the guessField). This is basically the method that makes the game run! In this method, you should read in the user's guess and check if it is valid. If it's not valid, update the displays. If the guess is valid, you should check if the user has guessed the letter already. If they have, update the displays. If it's a new guess, check if it is right or wrong and update the displays. Then also check if the game is over (either the user guessed the word and won or reached the maximum wrong guesses and lost). For full credit: add additional helper methods. Do not have the entire game logic in the handleGuessField method. Some examples of helpful methods might be isGuessValid, updateDisplays, getDisplayVersion OfSWord, etc. create whatever instance data variables you need to keep track of things. Some examples might be a list that keeps track of guessed characters, an array that keeps track of whether each character in the word has been guessed, the number of wrong guesses, etc. reduce duplicated code You can add code to the start() method to initialize variables and/or invoke helper methods. I strongly recommend getting the game working before moving on to Part II. I strongly recommend getting the game working before moving on to Part II. Part II: Exception Handling (30 points) Add exception handling to cover three erroneous occurrences. Note: I realize you could write a working game that accounts for these situations without using exception handling. But, for this project, you are required to use exception handling. For all three situations, create your own exception type(s) to represent the situation. When the situation occurs, throw an object of the type you just created. The program should catch the exception(s) and update the displays. . The user continues to guess after invalid guesses. Invalid guesses does not count against the user's wrong guess count. Erroneous situations: 1. The user enters an empty guess 2. The user enters a guess that is longer than one character (like aa or zb) 3. The user enters a guess that is not a letter (like + or $) Hint: check out the Character class for help with detecting this situation! Your program method should not terminate or crash because of any of these thrown exceptions. All thrown exceptions should be caught and handled and the game should continue. Extra Credit: 15 points Allow the user to play multiple games. Add a "play again" button that is only visible when the game is over. Choose a new random word for each game. Sample Program and Project Files Below is a sample program you can run. For this program, the game only chooses between three words, to make it easier for you to guess! The words are apple, banana, and pear. I strongly recommend getting the game working before moving on to Part II. Part II: Exception Handling (30 points) Add exception handling to cover three erroneous occurrences. Note: I realize you could write a working game that accounts for these situations without using exception handling. But, for this project, you are required to use exception handling. For all three situations, create your own exception type(s) to represent the situation. When the situation occurs, throw an object of the type you just created. The program should catch the exception(s) and update the displays. . The user continues to guess after invalid guesses. Invalid guesses does not count against the user's wrong guess count. Erroneous situations: 1. The user enters an empty guess 2. The user enters a guess that is longer than one character (like aa or zb) 3. The user enters a guess that is not a letter (like + or $) Hint: check out the Character class for help with detecting this situation! Your program method should not terminate or crash because of any of these thrown exceptions. All thrown exceptions should be caught and handled and the game should continue. Extra Credit: 15 points Allow the user to play multiple games. Add a "play again" button that is only visible when the game is over. Choose a new random word for each game. Sample Program and Project Files Below is a sample program you can run. For this program, the game only chooses between three words, to make it easier for you to guess! The words are apple, banana, and pear.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Draw a UML Sequence Diagram for the process involved in paying a vendor for an item in cash. The process to follow is below. [15 points] a) Go to the bank b) Request your account balance c) The bank...
-
Assume that Holloway Stores completed the following foreign-currency transactions: May 9 Purchased various inventory items on account from Toyita, a Japanese company. The price was 700,000 yen, and...
-
Differential Analysis for Machine Replacement Kim Kwon Digital Components Company assembles circuit boards by using a manually operated machine to insert electronic components. The original cost of...
-
How should you structure your fact investigation?
-
Here are some historical data on the risk characteristics of Dell and Microsoft: Assume the standard deviation of the return on the market was 15 percent. a. The correlation coefficient of Dell?s...
-
1- Financial ratio analysis is conducted by three main groups of analysts: credit analysts, stock analysts, and managers. What is the primary emphasis of each group, and how would that emphasis...
-
1. Mr. Albert has a piece of property he has used in his business for 25 years. He is moving his business across the country and needs to get rid of the real estate he currently owns, as he won't be...
-
1. Evaluate the current performance of the Administration Team in supporting the Departmental meetings. You should describe the feedback received and examples of good and poor practice. 2. Produce...
-
Cymbal E-Motors is a fast-growing start-up firm that manufactures electric motors for bicycles. The following income statement is available for April: Sales revenue (790 units @ $1,100 per unit) Less...
-
If z = x ^ 2 y + 3 xy ^ 4 , where x = sin 2 t and y = cos t , find dz / dt when t = 0 .
-
Is x = 7 in the domain of 7 -? X+7
-
Case 2: Two unknown force's magnitudes: T and T3. You will get values via calculations in this case. This time we give you all the angles, but two masses are unknown. That means we don't know two...
-
Step 2 of 2: Find the value of g(1). g(x)=-3x+3x+2
-
Using the estimation results in Question 5, test the null hypothesis that the mean test score in districts with low student-teacher ratio (STR <17) is equal to the mean test score in districts with...
-
A bubble-point liquid feed is to be distilled as shown in Figure. Use the Edmister group method to estimate the mole-fraction compositions of the distillate and bottoms. Assume initial overhead and...
-
Mike purchases a heavy-duty truck (5-year class recovery property) for his delivery service on April 30, 2012. The truck is not considered a passenger automobile for purposes of the listed property...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Jason and Mary Wells, friends of yours, were married on December 30, 2012. They know you are studying taxes and have come to you with a question concerning their filing status. Jason and Mary would...
-
(a) Consider a silicon pn junction diode operating in the forward-bias region. Determine the increase in forward-bias voltage that will cause a factor of 10 increase in current. (b) Repeat part (a)...
-
A silicon pn junction diode has an emission coefficient of \(n=1\). The diode current is \(I_{D}=1 \mathrm{~mA}\) when \(V_{D}=0.7 \mathrm{~V}\). (a) What is the reverse-bias saturation current? (b)...
-
(a) The reverse-saturation current of a gallium arsenide pn junction diode is \(I_{S}=10^{-22} \mathrm{~A}\). Determine the diode current for diode voltages of \(0.8,1.0\), \(1.2,-0.02,-0.2\), and...
Study smarter with the SolutionInn App