Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Hangman Game help
Post Flair (click to view more posts with a particular flair)
Post Body

Hey so the main problem I'm having is that every time somebody gets the letter wrong in hangman I want to start drawing the person right, but for some reason when u see my code it doesn't read it properly and places the message in the wrong places.

So this code right here prints out the message

void Hangman::printMessage(string message, bool printT = true, bool            printB = true) {
    if(printT) {
        cout << "*---------------------------------*\n";
        cout << "|";
        }
    else {
        cout << "|";
    }
    bool front = true;
    for(char i = message.length(); i < 33; i  ){
        if(front) {
            message = " "   message;
        }
        else {
            message = message   " ";
        }
        front = !front;
    }
    cout << message.c_str();
    if(printB) {
        cout << "|\n";
        cout << "*---------------------------------*\n";
    }
    else {
        cout << "|\n";
    }
}

and this code is supposed to start drawing the hangman

void Hangman::draw(int guess) {
    guess = 0;
    if(guess >= 1) {
        printMessage("/", false, false);
    }
    else {
        printMessage("", false, false);
    }
}

and this is in my main

int main() {
    Hangman h;
    h.printMessage("Hang Man", true, true);
    h.draw(1);
    getchar();
    return 0;

}

so for the printMessage function it does exactly what I need it to do the output is:

*---------------------------------*
|             Hang Man            |
*---------------------------------*

but in the draw function the output is:

*---------------------------------*
|             Hang Man            |
*---------------------------------*
|                                 |

while I am trying to get it as

*---------------------------------*
|             Hang Man            |
*---------------------------------*
                 /

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
626
Link Karma
73
Comment Karma
235
Profile updated: 1 day ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago