Question

Create a hangman program. Sample output from your program should look like the following: Current Status...

Create a hangman program.

Sample output from your program should look like the following:

Current Status for userInputs=
 _ _ _ _ _ _
Enter next letter: a

Current Status for userInputs=a
 _ _ _ _ _ _
Enter next letter: e

Current Status for userInputs=ae
 _ _ _ _ e _
Enter next letter: i

Current Status for userInputs=aei
 _ _ _ _ e _
Enter next letter: o

Current Status for userInputs=aeio
 _ o _ _ e _
Enter next letter: m

Current Status for userInputs=aeiom
 m o _ _ e _
Enter next letter: u

Current Status for userInputs=aeiomu
 m o _ _ e _
Enter next letter: n

Current Status for userInputs=aeiomun
 m o n _ e _
Enter next letter: k

Current Status for userInputs=aeiomunk
 m o n k e _
Enter next letter: y

Current Status for userInputs=aeiomunky
 m o n k e y

Congratulations: you guessed the word!!
Do you want to play object oriented Hangman again? (y or n): n
Bye



**************************************************************************
**************************************************************************

The following template gives you a starting point:

  
package object_oriented;

import java.util.*;

public class Hangman
{
    Scanner keyboard = new Scanner(System.in);
    Random rand = new Random();
    
    // The following routine will determine if the character c
    // is inside the String str.  A true is returned if it is inside.
    // It is very useful to call the isIn routine inside of printCurrStatus ...
    // See the comments in the Hint for printCurrStatus.
    
    boolean isIn(char c, String str)
    {
        //********** Fill in Details
    }
    
 // ******   printCurrStatus 

     // If userInputs contains "ard" and strToGuess contains "aardvark" then
     // the following routine prints out an output that looks something like:
     //
     // Current Status for userInpts=ard
     // a a r d _ a r _
     
     // This routine returns true if all letters were guessed, otherwise false is returned.

 // HINT:  It is useful to have a for loop that goes through each of the characters in
//         strToGuess.    Call isIn for each character (note the second parameter would 
//         be userInputs).   If isIn returns true, just print out the character, if isIn
//         returns false, then print out  '_'.  
//         Additionally, you can have a variable like:
//         boolean success = true;
//         Whenever you output at least one '_', you can set success = false.  
//         Your code can just return the variable "success" and it will return true if
//         the user has picked all of the letters.
     
    
    
    boolean printCurrStatus(String strToGuess, String userInputs)
    {
        //********** Fill in Details
    }
    
    // The following routine will return a random String from the list of words:
    // elephant, tiger, monkey, baboon, barbeque, giraffe,  simple, zebra, 
    // porcupine, aardvark
     
    String getNextWordToGuess()
    {
        final int num_words=10; // change this if you have a different number of words
        int num = rand.nextInt(num_words);
        // Another way to accomplish the same thing:
        // int num = (int)(num_words* Math.random());

        //********** Fill in Details
    }

    // The following routine plays the hangman game. It calls getNextWordToGuess to
    // get the word that should be guessed.  It then has a loop which outputs the 
    // following prompt:
    // Enter next letter
    //
    // A String named userInputs stores all letters selected already.  
    // Then the routine printCurrStatus is called to print out the current status of
    // the guessed word.  If printCurrStatus returns true, we are done.
     
    void playGame()
    {  
        //********** Fill in Details
        
    }
// main will call playGame to play the hangman game.
    // Then main will issue the prompt:
    // Do you want to play again (y or n)
    // If the answer is "y", then call playGame again, otherwise exit
    
    public static void main(String[] args)
    {
        Hangman hangman = new Hangman();
        
        String response="";
        do
        {
            hangman.playGame();
            System.out.print("Do you want to play object oriented Hangman again? (y or n): ");
            response = hangman.keyboard.next();
        } while (response.charAt(0) == 'y');
        
        System.out.println("Bye");
    }
}
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Create a hangman program. Sample output from your program should look like the following: Current Status...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • hey dear i just need help with update my code i have the hangman program i...

    hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...

  • Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1....

    Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1. Select a word at random from the wordBank. This is done for you. 2. On each turn display the word, with letters not yet guessed showing as *'s, and letters that have been guessed showing in their correct location 3. The user should have 10 attempts (?lives?). Each unsuccessful guess costs one attempt. Successful guesses do NOT count as a turn. 4. You must...

  • Please write this program in C++, thanks Task 9.3 Write a complete C++ program to create a music player Your program sh...

    Please write this program in C++, thanks Task 9.3 Write a complete C++ program to create a music player Your program should read in several album names, each album has up to 5 tracks as well as a genre. First declare genre for the album as an enumeration with at least three entries. Then declare an album structure that has five elements to hold the album name, genre, number of tracks, name of those tracks and track location. You can...

  • Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The...

    Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The computer must select a word at random from the list of avail- able words that was provided in words.txt. The functions for loading the word list and selecting a random word have already been provided for you in ps3 hangman.py. 2. The game must be interactive; the flow of the game should go as follows: • At the start of the game, let the...

  • JAVA MASTERMIND The computer will randomly select a four-character mastercode. Each character rep...

    JAVA MASTERMIND The computer will randomly select a four-character mastercode. Each character represents the first letter of a color from the valid color set. Our valid color choices will be: (R)ed, (G)reen, (B)lue and (Y)ellow. Any four-character combination from the valid color set could become the mastercode. For example, a valid mastercode might be: RGBB or YYYR. The game begins with the computer randomly selecting a mastercode. The user is then given up to 6 tries to guess the mastercode....

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