Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to create a java program that plays a game SIMILAR, but not exactly hangman. The assignment is for us to practice arrays, file

I need to create a java program that plays a game SIMILAR, but not exactly hangman. The assignment is for us to practice arrays, file input and strings. I have a seperate text file named hangman.txt where I have 10 phrases and I need the program to randomly chose 1 of those 10 phrases. I need to include a class contant for the number of incorrect guesses. I also need at least 6 public static methods that are

a method to load the input from a file into an array

a method to pick the puzzle for this game from the list of phrases

a method to play one game of word guess

a method to print the puzzle

a method to check if the puzzle is solved

a method to check if the guess was in the puzzle

Professor gave us a hint that you can solve this program creating exactly two arrays (one for the words read in from the file and one for the true/false values of whether or not to display a character). If you solve the problem this way, you will utilize string operation methods (like charAt) to look at each letter in the puzzle String. Alternatively, you can convert your puzzle from a string to an array and solve the problem treating the puzzle and whether or not to display each character as parallel arrays. Both ways are fine. I attached two pictures of sample outputs both losing and winning the game.

image text in transcribedimage text in transcribed

Example where the puzzle is not solved Let's play a game of word guess You can guess wrong up to 5 times Guess a letter > r r was found in the puzzle 1 times Guess a letterS S was found in the puzzle 1 times Guess a letter> t t was found in the puzzle 2 times Guess a letter >1 1 was found in the puzzle 1 times Guess a letter> n n was found in the puzzle 4 times Guess a letter > e e was found in the puzzle 2 times Guess a letter o o was found in the puzzle 1 times Guess a letterq q was not in the puzzle You have 4 more incorrect tries Guess a letter x x was not in the puzzle You have 3 more incorrect tries Guess a letterz z was not in the puzzle You have 2 more incorrect tries n te -eo- - Guess a letter> v v was not in the puzzle You have 1 more incorrect tries Guess a letter> m m was not in the puzzle You have more incorrect tries You have reached the max guesses The puzzle was Blackbird singing in the dead of night

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

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions