how would a class file and main file Java program be written with Character, String, and String Builder in which a user guesses letters and then attempts to guess a hidden word. It would display the word using symbols. When a letter guess is made by the player the letter is added to the correct place of the word and show the word again or return a message saying the guess is not in the word. Then add a message after the word has been guessed correctly. Guesses can be one letter or a word, if it's a word then make the program check if it's the same word as hidden by the symbols. The word guessed is randomly selected by the program from a list of 3 words by creating 3 different string variables and coding a random number between 1 and 5 to select the word. A clue would be shown to player with symbols replacing the words. If only one letter is entered then find all occurrences of that letter in the word. If attempt to guess the entire word its correct, then print a positive message. And correct, then print a positive message. And ask if they want to play again. Otherwise if the guess is wrong then tell them and ask for another guess. Also if one letter is guessed and it is part of the word then show all places that letter is used in the word. Or one letter is guessed and it's not part of the word then message user it's not in the word and ask for another guess. Ask user if they want to play again after word is shown. The program should loop so after each round so the user can choose to play again and a different phrase will be selected. The user class would contain one String variable for the player's name and one integer variable for the number of guesses. Include a function in the class that can reset the number of guesses at the beginning of each round. In the main file ask the user for their name and set it in the class. After each round has been completed and a message is printed, the message would include the player's name and the number of attempts it took them to guess the word.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

**************^^#}{{{{}%*+==++^#{]]]{}#^*+++++++++++++++

how would a class file and main file Java program be written with Character, String, and String Builder in which a user guesses letters and then attempts to guess a hidden word. It would display the word using symbols. When a letter guess is made by the player the letter is added to the correct place of the word and show the word again or return a message saying the guess is not in the word. Then add a message after the word has been guessed correctly. Guesses can be one letter or a word, if it's a word then make the program check if it's the same word as hidden by the symbols. The word guessed is randomly selected by the program from a list of 3 words by creating 3 different string variables and coding a random number between 1 and 5 to select the word. A clue would be shown to player with symbols replacing the words. If only one letter is entered then find all occurrences of that letter in the word. If attempt to guess the entire word its correct, then print a positive message. And correct, then print a positive message. And ask if they want to play again. Otherwise if the guess is wrong then tell them and ask for another guess. Also if one letter is guessed and it is part of the word then show all places that letter is used in the word. Or one letter is guessed and it's not part of the word then message user it's not in the word and ask for another guess. Ask user if they want to play again after word is shown. The program should loop so after each round so the user can choose to play again and a different phrase will be selected. The user class would contain one String variable for the player's name and one integer variable for the number of guesses. Include a function in the class that can reset the number of guesses at the beginning of each round. In the main file ask the user for their name and set it in the class. After each round has been completed and a message is printed, the message would include the player's name and the number of attempts it took them to guess the word.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

What if there's space in between the words? How will a space be added without a symbol in the hint ?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education