I need some major help with this hangman tutorial

Ok I have this tutorial for creating a hangman game. I am looking at it even trying to follow along with it and am having issues.

Here is the tutorial:

Functional Architectural Prototype
This section is designed to jump start your Functional Architectural prototype.  If you have brought up your source code editor or IDE and have sat there staring at a blank screen for an hour or two, unsure of how to proceed, then you've come to the right place.
You should already be familiar with how to start a new project using the Visual Studio.NET IDE. If you have difficulty with this, please contact your instructor immediately.
Change the #include statement to include iostream instead of stdio.h. Add an #include for stdlib.h (for the system call). Add a cout statement to display your name or "Hello World". Next add the line system("PAUSE"); before the return statement. Click Execute->Compile and Run. Type 'Main' in the Save File dialog, and click save. You should see a Console window that displays your message, and "Press any key to continue". Press a key and click the Continue button.
Right click on 'Term Project' and select 'New unit in project'. Declare the Menu class.
#ifndef _MENU_
#define _MENU_

#include <string>

using namespace std;
class Menu
    Menu(string filename);

#endif _MENU_
Now add the source file (Menu.cpp) & code the constructor.
#include "Menu.h"
Menu::Menu(string filename)
   cout << "The file name is..." << endl;
First compile and execute the project to make sure you have typed everything correctly.  Then modify your main() function to create and start your game.  Note that you will have to add the rest of your classes and stub out their interfaces before you will be able to compile again.
Here is an example main() function.  Note that the Game Constructor takes a Menu as an argument, so you will have to #include "Menu.h" in that class declaration.
Note: This code sample does not include the required header declarations.
int main(int argc, char *argv[])
    Menu myMenu("hangman.txt");
    Game myGame(myMenu);
    Controller myController(myGame);
    myController.start();   // Start the application
    return 0;
The Controller
In order to tie all of these classes together in a meaningful way, it is useful to add a little code into the Controller class; particularly in the start method.  The Controller manages the behavior of the entire application.  In our main() function (above) the Menu class was constructed with the name of the file that will be used to load/save our Hangman database.  The Game class is constructed with a reference to the Menu that administers it, and the Controller was constructed with a reference to the Game class.
Next main() passes control to the Controller by calling it's start() method.  So what happens in Controller::start()?  This Object Interaction diagram  (below) will hopefully shed some light on that question.
The Controller asks the Game for it's Menu and then enters a while loop, repeating the loop as long as the menu terminate() method returns false.  Each time through the loop, the Controller displays the Menu (Menu::display()) which returns a char command.  The Controller takes that char command and calls it's internal processCommand() method. Finally, processCommand() calls the Game::play() method.  Later on, you will add code to processCommand() to add, search, delete, play, etc., based upon the results returned from the Menu.
Hopefully, this section will provide you with enough information to allow you to complete your Functional Architectural Prototype.  Do not limit your Prototype to these few classes.  Think through how the Hangman game will work, and create the additional classes to support that functionality.
Once you do get your prototype working, it would be a very good idea for you to set your work aside somewhere safe, and start over from scratch (without using the tutorial).  Try to draw yourself a complete Object Model first.  With an understanding of the requirements and design, you should be able to code this handful of classes & make them interact appropriately without any help.
Here is a list of files you should now (at a minimum) have in your project if you are following the tutorial. They should each define the shell of a class, and each method should print a simple line of debug output to the Console.
Main.cpp       // Entry point for main() function
Controller.h       // Controller header file
Controller.cpp       // Controller source file
Game.h       // Game header file
Game.cpp       // Game source file
HangmanGame.h       // Hangman Game header file
HangmanGame.cpp       // Hangman Game source file
Menu.h       // Menu header file
Menu.cpp       // Menu source file
HangmanMenu.h       // HangmanMenu header file
HangmanMenu.cpp       // HangmanMenu source file
If you have completed the tutorial successfully so far, when you run your program, you will see some console output indicating several methods are being called in our various classes. If you look closely at the output, you may find that the HangmanGame and HangmanMenu methods are not being called. Why not?
Well, because we haven't constructed instances of those objects yet, that's why. Let's update our main() function and try again.
int main(int argc, char *argv[])
HangmanMenu myMenu("hangman.txt");
HangmanGame myGame(myMenu);
Controller myController(myGame);
myController.start(); // Start the application
return 0;
Now, if you have overridden the virtual method Game::play() in HangmanGame, then you should see that HangmanGame::play() is now being called. You will have to add the beginnings of a switch statement to Controller::processCommand() for this to work.
void Controller::processCommand(char command)
cout << "(debug) Controller::processCommand()" << endl;
case 'p':
cout << "I do not understand that command" << endl;
Now to display the Menu, put the (q)uit functionality in Menu::display(), and the other menu options in HangmanMenu::display(). We call up to the base class explicitly in HangmanMenu.
char HangmanMenu::display()
cout << "(debug) HangmanMenu::display()" << endl;
// Add the other menu options her
// (a)dd, (r)emove, (s)earch, (e)dit, (p)lay
return Menu::display();
If you've made it this far, you should be able to run your application, interact with the menu, and confirm the correct method HangmanGame::play() is being invoked when you choose (p)lay from the menu. Now you can go back and add the 'meat' to your application.
Who is Participating?
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
Is this an online tutorial? If so post me the link and I@ll look at it. I think any tutorial that states you have to have specific files without clarifying what they are or why you must have them isn't very good. The overall design of your architecture should dictate this, not the tutorial -- this isn't how code is written in the real world! Without any real knowledge of this tutorial, this is my guess at to what the files are meant to be: -

Main.cpp       // Entry point for main() function

This will be the starting point for your code, by convention most C/C++ programs place their main() function in main.c[pp] as it makes it simpler to find it :)

Controller.h       // Controller header file
Controller.cpp       // Controller source file

I suspect this will be your main program control loop, invoked directly from main. In here you'll put code that controls the general flow of the program

Game.h       // Game header file
Game.cpp       // Game source file

I suspect this will be an abstract class that will implement some basic 'game' like behavior (such as high score table maybe?).

HangmanGame.h       // Hangman Game header file
HangmanGame.cpp       // Hangman Game source file

I suspect this will be a sub-class of Game (derives from) and will provide the more specialist hangman behavior -- such as handling the guess!

Menu.h       // Menu header file
Menu.cpp       // Menu source file

I suspect this will be a generic menu class that will provide generic menu behavior such as scrolling or item selection or start and quit options.

HangmanMenu.h       // HangmanMenu header file
HangmanMenu.cpp       // HangmanMenu source file

This will probably be a sub-class of menu and will provide menu behavior that is specific to your game, such as choose level or maintain wordlist

Of course, I might be completely wrong, your guess is as good as mine. Like I said, I would just forget all about this pointless detail and just design your game based upon abstraction (after all this is what OOP is all about!).

Good luck my friend.

And what's your question ?
jschmuffAuthor Commented:
I've seen a lot of hangman game source code since I have been doing C++ and seen a lot of tutorials. I don't understand how I am supposed to make a class for everything and exactly where to really start I am a little lost this doesn't seem to be a complete tutorial. The only code I have is what is in the tutorial.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

jschmuffAuthor Commented:
In the tutorial it says at one point " Here is a list of files you should now (at a minimum) have in your project if you are following the tutorial. They should each define the shell of a class, and each method should print a simple line of debug output to the Console. " I don't see how I would have 11 files after that brief tutorial.
The tutorial seems to leave a lot of room for your own work ... ie. you have to fill in the gaps yourself.

Which part do you have a problem with ?
jschmuffAuthor Commented:
I've gotta goto work I will try this when I get home again and see where my first problem is and take notes.
evilrixSenior Software Engineer (Avast)Commented:
Well, you should start by NOT writing code but, rather, designing a solution on paper. Once you know what you want to do only then should you start cutting code!
jschmuffAuthor Commented:
Okay I starting writing down what I needed to do. The only thing that sucks is I don't have the slightest idea on how to create a hangman game. I read over this tutorial like 3 times followed along with it and get to the point where it says now you need to start adding all the other classes before you compile again. Is there anyway I can get help with like a base example of what it should follow, not the actual code for hangman. I really just don't see how I get 11 files for this.
evilrixSenior Software Engineer (Avast)Commented:
I usually start by deciding what classes are required. A simple way to do this is to look through the spec looking for all the nouns. These are usually representable as classes. All the verbs that perform actions on or with the nouns usually convert to class member functions. This is a rule of thumb and it's not an exact science but it's a good place to start.

You should draw a class diagram that shows all the relationships between the classes and the actions they can perform. This is a planning stage and from this you should start to see if your noun/verb assumptions are reasonable. Any bad assumptions should be obvious and you'll have to re-think them. Once this is complete you will have an architectural design that you can then start working from.

This links discuss how to draw and use UML class diagrams: -


NB. The design phase is usually the hardest the takes the longest. Just to give you an idea, as a rule of thumb a well designed and written application will probably have split time 80% design and 20% coding.

jschmuffAuthor Commented:
I know the UML thing thx for the link though very useful my main problem is how it is going to look I have ideas about how hangman works but unsure what is the difference between game.h /.cpp and hangmanGame.h /.cpp and dont really understand what I would put in controller.h/ .cpp and the same what is the difference of menu.h/.cpp and hangmanMenu.h/.cpp files?? there is a big confusion there. Just having those confusions makes it hard to even set up a design for the game.
evilrixSenior Software Engineer (Avast)Commented:
I wouldn't worry about details too much just yet -- at this stage just worry about the abstract. Try and figure out the building blocks for the game without worrying too much about how you'll implement them. Design and implementation details should be kept separate at this easy stage. Just try and figure out at a very abstract level what building blocks your game needs and how they'll interact. Only once you have this should you start worrying about the detail. This is called top down design (also called stepwise refinement) and is a core principle of modeling when designing OO programs.


It works on the premise that you shouldn't worry about the detail until you need to. You start off with abstract building blocks and then keep refactoring until you get to where you need top go. It's different from the normal bottom up approach taken by procedural programmers where they generally worry about the detail and then try to figure out how to link it all together later. This is normally fine for procedural programming but can hinder OO programming. In the end there is nothing that can replace good planning!

I know this probably isn't what you want to hear but ultimately there are no short-cuts to a good design, it takes time, patience and often a lot of refactoring! If it was simple everyone would be doing it and us software architects wouldn't get paid the big bucks :)

jschmuffAuthor Commented:
I agree with you there and thx for the links but I still have the question what is the difference between hangmanMenu and the menu files. Why would I need to have two what would be the difference in them. I just dont understand why so many files and that makes it hard to even understand what I need.
jschmuffAuthor Commented:
ok before I go back to work one more thing like I know that the menu will have Add, Delete, Edit, Search, Play Game, Quit... My real question is what will the hangman menu have... and the same goes for the other files where they have a different name counterpart. Like I said up top game and hangmanGame two seperate files this is the tutorial requirements so what would I have in the other that wouldn't be in the first.
evilrixSenior Software Engineer (Avast)Commented:
I thought this might interest you...

jschmuffAuthor Commented:
Thank you very much that helps out a lot actually I will post more when or if I get it done.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.