Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order


create the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. 

Requirements

Rules

The program will use 10 to 15 words as its pool for users to guess from. You may pick your own words. The words must be between 5 to 10 characters each. In a traditional hangman game, the person guessing can make 8 incorrect guesses. Each correct guess of a letter does not count against the number of incorrect guesses. When the player reaches 8 incorrect guesses, the game is over.

When the user starts the program, one of the words from the list will be chosen at random for the user to guess. Before the user starts, the program will show the word as a series of asterisks (*) where each letter is replaced with an asterisk (*). For example, if the word is dragon, the user will be given the message, "Please guess the following word * * * * * * . You have 7 wrong guesses left".

As the game progresses, the user will guess letters one at a time. Each time the user guesses a letter, the program will either reveal the letters in the word that match, give a warning that they guessed a letter they already had guessed or that the letter does not exist in the word. After a guess, the program will output the message, with all of the currently solved letters and the rest of the unknown letters still replaced by * and then a count of how many wrong guesses left.

Each time the user either chooses a letter that is wrong or that they have already chosen, the program will deduct a guess from the number of tries they have left. After they have exhausted all of their guesses, the program will output a message that they have lost and offer to let them play again. If they solve the word, then the program will display a congratulatory message and ask them if they wish to play again.

Each subsequent play-through will not allow a previously used word to be chosen so be sure to keep track of these words through some method. If there are no more words to choose then the program needs to end with a message saying in some manner that it is out of words, thanks for playing and have a nice day.

Java Requirements

The program must utilize single dimensional arrays to track the state of the program. At a minimum, you will need one array of characters to track the current word, you will need one array of words to track which words have been chosen or are left to be chosen. How you define the logic and utilize these arrays is up to you.

The program must be created from an object oriented perspective. You will likely want a functionfor running the game, one for picking the words, another for judging if a letter is in the word, etc. The program should not use the main method for the majority of the functionality. Hint: If the program has to "perform a task", that task can likely be made into a function or method.

Once you have it working as expected upload the .java file to this assignment drop box. You must also submit a Word doc or text file containing the Java code. Assignments not containing both the Java code and the text or Word file will be assigned a 0 for a grade.

Step by Step Solution

3.38 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

The answer provided below has been developed in a clear step by step manner Step 1 Solution Your Code import javautilArrayList import javautil import javaioFile import javaioFileNotFoundException impo... 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_2

Step: 3

blur-text-image_3

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

Horngrens Accounting

Authors: Tracie L. Miller Nobles, Brenda L. Mattison, Ella Mae Matsumura, Carol A. Meissner, Jo Ann L. Johnston, Peter R. Norwood

10th Canadian edition Volume 1

978-0134213101, 134213106, 133855376, 978-0133855371

More Books

Students also viewed these Programming questions

Question

What is a compound journal entry?

Answered: 1 week ago