Question

Overview In this exercise you are going to recreate the classic game of hangman. Your program...

Overview

In this exercise you are going to recreate 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 a number of 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 function for running the game, one for picking the words, another for judging if a letter is in the word, etc. If you load up your main() with all or most of the functionality, you will be penalized harshly. Hint: If the program has to "perform a task", that task can likely be made into a function or method.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hangman game is like tic-toc game.Here user guess the  one letter after that prompt will be guess another letter like the game continues.Here first one word will be displayed user need to be guess the correct word.If user fails then game will be ended or if user win then it will displays the number of misses he did.The word appears on the screen is like astrek's..******

code

//These are the library functions needed to program to work

Import java.io.*;

Import java.util.*;

import java.util.Arrays;

import java.util.Scanner;

//create a class with grame name

public class Hangman_game{

    public static void main(String[] args) {

        String[] wds = {"movie", "released", "soon",”waiting”};

                Int k=0;

        // first need to pick the index randomly

//so here we wrote the math.random function to work

        int rdmwdsnum = (int) (Math.random() * wds.length);

        // here we are creating the array for storing purpose

        char[] io_leters= new char[wds[rdmwdsnum].length()];

System.out.println(“ “);

        int try_Cnt = 0;

       boolean Guesedwds= false;

        do {

        // we will iterate this work till we get true it is false then user guessed the all the letters

        switch (enter_Letter(wds[rdmwdsnum], entered_Letters)) {

            case 0:

                try_Cnt++;

                break;

            case 1:

                try_Cnt++;

                break;

            case 2:

                   k++;

                    break;

            case 3:

                Guesedwds= true;

                break;

        }

        } while (! wordIsGuessed);

        System.out.println("\nHere the word is " + wds[rdmwdsnum] ;

                System.out.println(“ You missed “ + (try_Cnt -findEmptyPosition(enteredLetters)) +” times(s));

    }

Output is like this

Enter a guessed letter in word **** > m

Enter a guessed letter in word **a* > v

Enter a guess letter in word t*at > r

r letter is not in the word lisrt

Enter a guess letter in word t*at > m

m letter is already in the that word

The actual word is that missed 3 time(s)..oops

Add a comment
Know the answer?
Add Answer to:
Overview In this exercise you are going to recreate the classic game of hangman. Your program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program...

    Please help with this Intro to programming in C assignment! Intro to Programming in C-Large Program 3 - Hangman Game Assignment purpose: User defined functions, character arrays, c style string member functions Write an interactive program that will allow a user to play the game of Hangman. You will need to: e You will use four character arrays: o one for the word to be guessed (solution) o one for the word in progress (starword) o one for all of...

  • Hangman is a game for two or more players. One player thinks of a word, phrase...

    Hangman is a game for two or more players. One player thinks of a word, phrase or sentence and the other tries to guess it by suggesting letters or numbers, within a certain number of guesses. You have to implement this game for Single Player, Where Computer (Your Program) will display a word with all characters hidden, which the player needed to be guessed. You have to maintain a dictionary of Words. One word will be selected by your program....

  • Create the game hangman using c code: Program description In the game of hangman, one player...

    Create the game hangman using c code: Program description In the game of hangman, one player picks a word, and the other player has to try to guess what the word is by selecting one letter at a time. If they select a correct letter, all occurrences of the letter are shown. If no letter shows up, they use up one of their turns. The player is allowed to use no more than 10 incorrect turns to guess what the...

  • javafx assisantance confused on where to start Problem Description: (Game: hangman) Write a JavaFX program that...

    javafx assisantance confused on where to start Problem Description: (Game: hangman) Write a JavaFX program that lets a user play the hangman game. The user guesses a word by entering one letter at a time, as shown in Figure followings. If the user misses seven times, a hanging man swings, as shown in Figures. Once a word is finished, the user can press the Enter key to continue to guess another word. Guess a word: ***** God Missed letters Guess...

  • C++ Hangman (game) In this project, you are required to implement a program that can play...

    C++ Hangman (game) In this project, you are required to implement a program that can play the hangman game with the user. The hangman game is described in https://en.wikipedia.org/wiki/Hangman_(game) . Your program should support the following functionality: - Randomly select a word from a dictionary -- this dictionary should be stored in an ASCII text file (the format is up to you). The program then provides the information about the number of letters in this word for the user to...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • This is for C programming: You will be given files in the following format: n word1...

    This is for C programming: You will be given files in the following format: n word1 word2 word3 word4 The first line of the file will be a single integer value n. The integer n will denote the number of words contained within the file. Use this number to initialize an array. Each word will then appear on the next n lines. You can assume that no word is longer than 30 characters. The game will use these words as...

  • JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The...

    JAVA Hangman Your game should have a list of at least ten phrases of your choosing.The game chooses a random phrase from the list. This is the phrase the player tries to guess. The phrase is hidden-- all letters are replaced with asterisks. Spaces and punctuation are left unhidden. So if the phrase is "Joe Programmer", the initial partially hidden phrase is: *** ********** The user guesses a letter. All occurrences of the letter in the phrase are replaced in...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • Consider a class that could be used to play a game of hangman. The class has...

    Consider a class that could be used to play a game of hangman. The class has the following attributes: The secret word. The disguised word, in which each unknown letter in the secret word is replaced with a question mark (?). For example, if the secret word is abracadabra and the letters a, b, and e have been guessed, the disguised word would be ab?a?a?ab?a. The number of guesses made. The number of incorrect guesses. It will have the following...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT