-2

I dont understand how to do this, my teacher suxs at teaching. He's a smart guy, just a really dumb teacher.. Have you ever had one of those teachers? Its a pain. Anyways This is due before 12am tonight..Please Help me solve it:::

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

C:\work>java Hangman
Current Status for userInpts=
_ _ _ _ _ _ _
Enter next letter
a

Current Status for userInpts=a
_ _ _ a _ _ _
Enter next letter
e

Current Status for userInpts=ae
_ _ _ a _ _ e
Enter next letter
f

Current Status for userInpts=aef
_ _ _ a f f e
Enter next letter
g

Current Status for userInpts=aefg
g _ _ a f f e
Enter next letter
i

Current Status for userInpts=aefgi
g i _ a f f e
Enter next letter
r

Current Status for userInpts=aefgir
g i r a f f e
Congratulations: you guessed the word!!
Do you want to play again? (y or n)
y
Current Status for userInpts=
_ _ _ _ _ _
Enter next letter
a

Current Status for userInpts=a
_ a _ _ _ _
Enter next letter
b

Current Status for userInpts=ab
b a b _ _ _
Enter next letter
c

Current Status for userInpts=abc
b a b _ _ _
Enter next letter
o

Current Status for userInpts=abco
b a b o o _
Enter next letter
n

Current Status for userInpts=abcon
b a b o o n
Congratulations: you guessed the word!!
Do you want to play again? (y or n)
y
Current Status for userInpts=
_ _ _ _ _ _
Enter next letter
a

Current Status for userInpts=a
_ _ _ _ _ _
Enter next letter
e

Current Status for userInpts=ae
_ _ _ _ e _
Enter next letter
i

Current Status for userInpts=aei
_ _ _ _ e _
Enter next letter
o

Current Status for userInpts=aeio
_ o _ _ e _
Enter next letter
p

Current Status for userInpts=aeiop
_ o _ _ e _
Enter next letter
m

Current Status for userInpts=aeiopm
m o _ _ e _
Enter next letter
n

Current Status for userInpts=aeiopmn
m o n _ e _
Enter next letter
k

Current Status for userInpts=aeiopmnk
m o n k e _
Enter next letter
y

Current Status for userInpts=aeiopmnky
m o n k e y
Congratulations: you guessed the word!!
Do you want to play again? (y or n)

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

Your program should fit the following programming structure:s

import java.util.*;

    class Hangman
    {
        static Scanner scan = new Scanner(System.in);
        static Random rand = new Random();
        
        // The following routine will determin if the character c
        // is inside the String str.  A true is returned if it is inside.
        
        static boolean isIn(char c, String str)
        {
           String str1.rand;
           if (str1.indexOf('c')!=-1);
                   return true;
          
         
        
        // 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.
        
        
        static boolean printCurrStatus(String strToGuess, String userInputs)
        {
            System.out.println("");

        }
        
        // The following routine will return a random String from the list of words:
        // elephant, tiger, monkey, baboon, barbeque, giraffe,  simple, zebra, 
        // porcupine, aardvark
         
        static String getNextWordToGuess()
        {
            switch (strToGuess)
            {
            case 1:
                str1 = "elepahnt";
                break; 
            case 2: 
                str1 = "barbeque";
            case 3: 
                str1 = "giraffe";
            case 4: 
                str1 = "simple";
            case 5: 
                str1 = "Zebra";
            case 6: 
                str1 = "porcupine";
            case 7: 
                str1 = "aardvark";
            default:  
            }
        }
        
        // 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.
         
        static 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)
        {
            //********** Fill in Details
        }
    }
}

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code

Votes + Comments
Do it for me I need more time on my Xbox
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by harinath_2007
0

You have your requirements and everything in crystal clear manner. All you have to do is learn the java syntax and some API classes and start coding yourself. No one takes the pain of doing your homework . It's your homework and pain is also yours .
Atleast try some code and ask doubts if you are stuck somewhere while coding..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.