### Hangman

I'm a beginner in programming, just started to work in some projects and one of them is a "CANT WIN HANGMAN GAME" and need help finishing it. This is what I have at this time:

My gallows.h file
 ``1234567891011121314151617181920212223`` ``````#ifndef GALLOWS_H #define GALLOWS_H #include using namespace std; class GallowsPole { public: GallowsPole(); ~GallowsPole(); int counter(); void draw0(); void draw1(); void draw2(); void draw3(); void draw4(); void draw5(); void draw6(); private: int count; }; #endif ``````

My gallows.cpp file:
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159`` ``````#include #include #include "gallows.h" using namespace std; // define your methods here GallowsPole::GallowsPole() {count=0; } GallowsPole::~GallowsPole(){} int GallowsPole::counter() { int tries,guess; char letter; tries=6; guess=0; do { if (guess==0) { cout<<"HANGMAN"<>letter; guess++; //guess=count; } else if(guess==1) { cout<<"Make your second guess: "<>letter; guess++; //guess=count; } else if (guess==2) { cout<<"Make your third guess: "<>letter; guess++; //guess=count; } else if (guess==3) { cout<<"Make your fourth guess: "<>letter; guess++; //guess=count; } else if (guess==4) { cout<<"Make your fifth guess: "<>letter; guess++; //guess=count; } else if (guess==5) { cout<<"Make your sixth and last guess!: "<>letter; guess++; //guess=count; } else if (guess==6) { cout<<"YOU LOST"<

And my main .cpp file:
 ``123456789101112131415`` ``````#include using namespace std; #include "gallows.h" int main() { int a; GallowsPole g; a=g.counter(); system("PAUSE"); return 0; }``````

Up to now the program asks the user for 6 guesses, but I'm having trouble figuring out how to keep count of the tries in order to display my void draw methods!

Please any help will be aprreciated
Last edited on
why not put the draw method which corresponds to the guess number within the guess block?

 ``12345678`` ``````else if (guess==6) { cout<<"YOU LOST"<
Last edited on
Well thank you pogrady! Works fine now!
Better to create public GallowsPole::draw() method which will call draw0()–draw6() methods based on private variable and make draw0()–draw6() methods private.
Topic archived. No new replies allowed.