83.2 Hangman Logic

696 views
Skip to first unread message

Dee

unread,
Nov 13, 2014, 8:39:11 AM11/13/14
to moo...@googlegroups.com
Hi,

I'm having problems with week _4_ exercise _38.2__.

For some reason, when running the program it doesn't show the hangman GUI/image or anything except the menu texts. Is this normal?

Failing these two test.
Error:
(1)The guessed letter should be included to the already guessed letters.

(2)ComparisonFailure: When the word MOOC has letter O correctly guessed,the hidden word should be _OO_ expected:<_[OO]_> but was:<_[__]_>





Best regards
___________


Please use our build in TMC Pastebin when asking questions related to your code 

In NetBeans, select TMC -> Send code to TMC pastebin. Copy the link you receive and paste it to your message.  

You may use our web interface to share code snippets: http://paste.mooc.fi

Joni

unread,
Nov 17, 2014, 5:17:38 AM11/17/14
to moo...@googlegroups.com
Hi,

I suggest that you start from the start, here is a template which might help you to get started.

public void guessLetter(String letter) {
    // if the letter has already been guessed, nothing happens
        // PROTIP: You can quit current method with return; statement
    // Else if Letter hadn't been guessed already
        // Append letter to guessed letters
        // If Word we are trying to guess doesn't contain letter
            // Increase numberOfFaults
}

public String hiddenWord() {
    // Declare empty Hidden word where start appending letters
    // Loop thru word we are trying to guess
        // If character at index i has been guessed already
            // PROTIP: You can check if String contains character by using wordString.contains("" + letterChar);
            // Add letter to Hidden word
        // Else if char hadn't been guessed append "_" to Hidden word
    // Return Hidden Word
}

Best regards
Joni
Reply all
Reply to author
Forward
0 new messages