hangman hang-up for java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hellocity
    New Member
    • Dec 2009
    • 1

    hangman hang-up for java

    I’m trying to make a hangman program that starts with dashes, maybe some letters already showing, and you type in guess’. After each guess the “dashes” refresh and the missed letters refresh until you exceed 7 guesses or complete the word.

    My logic so far is:
    Print “You will have 7 chances to guess” //head, body, two legs, two arms, face
    Print _ _ _ _ _ _! //for now there will only be one option
    Print “Choose a Letter” input from the keyboard
    If correct print _ _ _E _ _! For each option and save
    If incorrect add letter to Missed: A F G
    If word is filled out, print “Congrats”
    If # of guess exceeds 7 print “Try again” and quit.

    I think this would be the right logic for a super simple hangman game…I think I can work everything out but I’m having trouble with step 4 where the program knows you picked a letter, places it and saves it for the next guess. Any advice or guidance would be greatly appreciated, thanks
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Step 4:
    Use a StringBuffer object to store the incomplete string from the user. You can access it like an array and set single characters inside directly (on opposition to the non-modifiable String object)

    or do you mean Step 5?

    Step 5:
    use Vector or ArrayList to store all the letters which were already guessed.

    Comment

    Working...