Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need help coding a simple Hangman game

    Hello everybody!

    For a class project, I am creating a simple version of Hangman.
    The phrase the user has to figure out will be "My teacher is the best."
    When it starts out, it will print "-- ------- -- --- ----." Please enter a letter.

    I am having some trouble, however, with the script being able to read the letter I enter and replace it with the corresponding hyphen.

    So when you type in "e", the script prints out "-- -e---e- -- --e -e--."
    And then they enter a "t", it will print out "-- te---e- -- t-e -e-t."
    Until each letter is guessed

    How do you do that?

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    You will have to be much more specific to get anywhere with your question.

    Have you started the program?
    What have you tried?
    What part is giving you trouble?

    I would start with a String that contains the actual key, and use the standard methods supported by the String class to read where and at what index each character resides.

    Alternatively, you could use a character array and access the string as a standard array, but I would go with using a String.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •