Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,578 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,968 people online right now. Registration is fast and FREE... Join Now!




Hangman Game Project

 
Reply to this topicStart new topic

Hangman Game Project

Thomsoningreen
2 Oct, 2008 - 07:07 PM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2008
Posts: 5


My Contributions
pirate.gif icon_up.gif ph34r.gif This Project I have won't compile right it gives me about 40 errors and it seems to be missing something. mad.gif


Game.h
CODE
// Base class Game.h
#ifndef Game_h
#define Game_h
#include <string>
using namespace std;

struct BODY      // this is my structure that holds all the pieces of Hangman for when
{              // he get's drawed to the screen.

    char head, head2, headCLT, headMT, headCRT, headCLB, headMB, headCRB,
         neck,
         shoulders, shouldersL, shouldersM, shouldersR,
         arm1, arm2,
         body,
         hips, hipsL, hipsM, hipsR,
         leg1, leg2;
}; // eof structure BODY

class Game
{
    //Overload the stream insertion and extraction operators
    friend ostream& operator<< (ostream&, const Game &);
    friend istream& operator>> (istream&, Game &);

public:

    virtual void play();
    Game(); // constructor
    Game(const Game &game); // copy constructor

protected:

    string skipWord, plyrName;
    char *hmWord, guess, startLet;
    int letAmount, guessAmount, correct,
        score, letValue;
    bool gameOver;

};
#endif


Game.cpp
CODE
#include "Game.h"
#include <iostream>

using namespace std;

ostream& operator<< (ostream& osObject, const Game& theGame)
{
    osObject << "Player's name:" << theGame.plyrName; //Display player's name
    return osObject;
}
istream& operator>> (istream& isObject, Game& theGame)
{
    isObject >> theGame.plyrName; //Gets player's name
    return isObject;
}
Game::Game()
{
    letAmount = 0;    // letAmount is amount of letters that are in our hangman word
    guessAmount = 0;  // guessAmount is the amount of guesses that the player as made wrong
    correct = 0;      // correct is the amount of correct guesses the player as made
    score = 0;          // score is what holds the total points scored by the player
    letValue = 0;     // letValue is what holds the value of the current letter guessed and how
                      // it effects the players score
    startLet = 97;    // startLet is just a "char" used to signify what ASCII code for the
                      // first letter in the alphabet is (lowercase) 97 = 'a' && 122 = 'z'
    gameOver = false; // gameOver is our boolean which gets returned to the method "isGameOver" to
                      // see if our game is over or not. = ]


    for(int abc = 0; abc < 27; abc++) // Loop to store lowercased alphabet
    { //alpha[] just holds the alphabet (size of array is 27)
        alpha[abc] = startLet; // this asigns the first subscript of alpha to a lowercased 'a'

        startLet++; // this increases startLet by one which will make it a lowercase 'b'
    }            

    for(int letG = 0; letG < 27; letG++)
        letGuessed[letG] = 32;             // letGuessed holds all the letters that the player has guessed.

    for(int hmlt = 0; hmlt < 7; hmlt++)
        hmLetters[hmlt] = 32;            // hmLetters holds all the letters that the player as guessed correctly
                                        // that were part of the word


    hmWord = new char[letAmount];
}
Game::Game(const Game &game)
{
    letAmount = game.letAmount;
    guessAmount = game.guessAmount;
    correct = game.correct;
    score = game.score;
    letValue = game.letValue;
    gameOver = game.gameOver;

    for(int abc = 0; abc < 27; abc++)
        alpha[abc] = game.alpha[abc];

    for(int letG = 0; letG < 27; letG++)
        letGuessed[letG] = game.letGuessed[letG];

    for(int hmlt = 0; hmlt < letAmount; hmlt++)
        hmLetters[hmlt] = game.hmLetters[hmlt];

    for(int hm = 0; hm < letAmount; hm++)
        hmWord[hm] = game.hmWord[hm];
}

void Game::play()
{
    bool guessLet(char [], char &, int, int, int, bool &);
    {
    if(correct == letAmount) // checks to see if the player has made the correct
    {                         // amount of guesses and if the player as, then display
        cout << endl;         // a "Winner" message and end game!
        cout << "\t\t\tCongratulations! You Saved Hangman! You Win!\n";
        cout << endl;
        gameOver = true;
            return gameOver;
    }

    if(guessAmount == 9) // checks to see if the player has made to many incorrect
    {                     // guesses, and if the player as made 9 incorrect guesses then
        cout << endl;    // display a "Lost" message and end game!
        cout << "\t\t\tGame Over! Better Luck Next Time!\n";
        cout << endl;
        gameOver = true;
            return gameOver;
    }

    // Ask the user to guess a letter = ]
    cout << endl << "\t\tGuess a letter that you think is in the word? ";
    cin >> guess; // asigns "guess" to the letter the player guessed

    guess = tolower(guess); // "tolower()" takes the value of that variable
                            // and makes it lower case.

    return 0; // returns false
    }
    void checkGuess(char, char [], char [], char [], char [], int &, int &, int);
    {
    // If guess is correct:
    for(int i = 0; i < letAmount; i++)
    {
        if(guess == hmWord[i])
        {                      
            correct++;

            hmLetters[i] = hmWord[i];

            for(int s = 0; s < 27; s++)
            {
                if(guess == alpha[s])
                {
                    letValue = s + 1;                 
                    score += letValue;
                    letGuessed[s] = alpha[s];
                } // eof if(guess == alpha[s])
            } // eof for(int s = 0; s < 27; s++)
        } // eof if(guess == hmWord[i])
    } // eof for(int i = 0; i < letAmount; i++)

    // If the word was incorrect:

    if( (guess != hmWord[0]) && (guess != hmWord[1]) && (guess != hmWord[2]) && (guess != hmWord[3]) && (guess != hmWord[4]) && (guess != hmWord[5]) && (guess != hmWord[6]) )
    {
        guessAmount++;

        for(int s = 0; s < 27; s++)
        {
            if(guess == alpha[s])
            {
                letValue = s + 1;
                score -= letValue;

                if(score < 0) score = 0;

                letGuessed[s] = alpha[s];

            } // eof if(guess == alpha[s])
        } // eof for(int s = 0; s < 27; s++)
    } // eof if( (guess != hmWord[0]) && (guess != hmWord[1]) && (guess != hmWord[2]) && (guess != hmWord[3]) && (guess != hmWord[4]) && (guess != hmWord[5]) && (guess != hmWord[6]) )
    }

}


Controller.h
CODE
#ifndef Controller_h
#define Controller_h

#include "Dictionary.h"
#include "Menu.h"


class Controller
{

public:

    virtual void Start(char word,char inChar);

    Menu myMenu;

    Dictionary myDictionary;
};
#endif

Controller.cpp
CODE
#include <iostream>
#include "Controller.h"

using namespace std;

void Controller::Start(char word,char inChar)
{
    while ((myMenu.getChoice() != 'Q') && (myMenu.getChoice() != 'q')) // Main loop //***define hmenu***
    {
        switch (myMenu.getChoice())
        {
            case 'A':
            case 'a':
                cout << "Please enter a new word: ";
                cin >> word;
                
                cout << endl << "The added word is: " << word << endl; // Just to see if it works
                break;
            case 'D':
            case 'd':
                cout << "Which word would you like to delete? ";
                cin >> word;
                
                cout << endl << "The deleted word is: " << word << endl; // Just to see if it works
                break;
            case 'L':
            case 'l':
                cout << endl << "List under construction... " << endl; // Just to see if it works
                
                break;
            case 'S':
            case 's':
                cout << "Which word are you looking for? " << endl; // Just to see if it works
                cin >> word;
                cout << endl << "Searching..." << endl << "Database under construction..." << endl;
                break;
            case 'P':
            case 'p':
                cout << "User selected play game!" << endl; // Just to see if it works
                break;
            default:
                cout << "Invalid selection." << endl;
        }// End switch
        
        myMenu.displayMenu();
        myMenu.displayChoice();
        cin >> inChar;
        myMenu.setChoice(inChar);
    }// End while
}

HangmanGame.h
CODE
//Definition for class HangmanGame.h (Derived class from Game.h)

#ifndef HangmanGame_h
#define HangmanGame_h

#include "Game.h"


class HangmanGame : public Game
{

public:

    virtual guess();

    virtual void showHangMan();

    virtual void showScreen();
};
#endif

HangmanGame.cpp
CODE
#include "HangmanGame.h"
#include <iostream>
#include <string>

using namespace std;

BODY body;    //Global instance of Hangman's body


HangmanGame::guess()
{
    Game::play();
}

void HangmanGame::showHangMan(BODY &body, int guessAmount)
{
    if(guessAmount == 0) // this is asigns all of hangman's body parts to equal space
    {
        body.head, body.head2, body.headCLT, body.headMT, body.headCRT,
        body.headCLB, body.headMB, body.headCRB,
        body.neck,
        body.shoulders, body.shouldersL, body.shouldersM, body.shouldersR,
        body.arm1, body.arm2,
        body.body,
        body.hips, body.hipsL, body.hipsM, body.hipsR,
        body.leg1, body.leg2 = (char)32;
    }
    else if(guessAmount == 1) // when one miss guess is made this draws his head
    {
        body.head = (char)196;
        body.head2 = (char)179;
        body.headCLT = (char)218;
        body.headMT = (char)193;
        body.headCRT = (char)191;
        body.headCLB = (char)192;
        body.headMB = (char)196;
        body.headCRB = (char)217;
    }
    else if(guessAmount == 2) // when another miss is made this draws in his neck
    {
        body.headMB = (char)194;
        body.neck = (char)179;
    }
    else if(guessAmount == 3) // then next drawn in is his shoulders
    {
        body.shoulders = (char)196;
        body.shouldersL = (char)196;
        body.shouldersM = (char)193;
        body.shouldersR = (char)196;
    }
    else if(guessAmount == 4) // after that is his left arm to be drawn in
    {
        body.shouldersL = (char)218;
        body.arm1 = (char)179;
    }
    else if(guessAmount == 5) // next missed guess would then drawn in his right arm
    {
        body.shouldersR = (char)191;
        body.arm2 = (char)179;
    }
    else if(guessAmount == 6) // after that, his body gets drawn in
    {
        body.shouldersM = (char)197;
        body.body = (char)179;
    }
    else if(guessAmount == 7) // then hangman's hips are drawn in
    {
        body.hips = (char)196;
        body.hipsL = (char)196;
        body.hipsM = (char)193;
        body.hipsR = (char)196;
    }
    else if(guessAmount == 8) // then his left leg is drawn in
    {
        body.hipsL = (char)218;
        body.leg1 = (char)179;
    }
    else if(guessAmount == 9) // then last would be his right leg to be drawn in
    {
        body.hipsR = (char)191;
        body.leg2 = (char)179;
    }
}
void HangmanGame::showScreen(BODY body, string plyrName, char hmLetters[], char letGuessed[], int score, int letAmount)
{
    system("CLS");
    cout << endl << endl;
    cout << "\t\t                             Hangman                   \n";
    cout << "\t\t       " << (char)218 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)191 << "  \n";
    cout << "\t\t       " << (char)179 << "              " << (char)179 << "  \n";
    cout << "\t\t       " << (char)179 << "              " << (char)179 << "  \n";
    cout << "\t\t       " << (char)179 << "            " << body.headCLT << body.head << body.headMT << body.head << body.headCRT << "     Players Name: " << plyrName << "\n";
    cout << "\t\t       " << (char)179 << "            " << body.head2 << "   " << body.head2 << "            Score: " << score << "\n";
    cout << "\t\t       " << (char)179 << "            " << body.head2 << "   " << body.head2 << "     \n";
    cout << "\t\t       " << (char)179 << "            " << body.headCLB << body.head << body.headMB << body.head << body.headCRB << "\n";
    cout << "\t\t       " << (char)179 << "              " << body.neck << "              " << hmLetters[0] << " " << hmLetters[1] << " " << hmLetters[2] << " " << hmLetters[3] << " " << hmLetters[4] << " " << hmLetters[5] << " " << hmLetters[6] << " \n";
    if(letAmount == 7)
        cout << "\t\t       " << (char)179 << "           " << body.shouldersL << body.shoulders << body.shoulders << body.shouldersM << body.shoulders << body.shoulders << body.shouldersR << "           - - - - - - -\n";
    else if(letAmount == 6)
        cout << "\t\t       " << (char)179 << "           " << body.shouldersL << body.shoulders << body.shoulders << body.shouldersM << body.shoulders << body.shoulders << body.shouldersR << "           - - - - - -\n";
    else if(letAmount == 5)
        cout << "\t\t       " << (char)179 << "           " << body.shouldersL << body.shoulders << body.shoulders << body.shouldersM << body.shoulders << body.shoulders << body.shouldersR << "           - - - - -\n";
    else if(letAmount == 4)
        cout << "\t\t       " << (char)179 << "           " << body.shouldersL << body.shoulders << body.shoulders << body.shouldersM << body.shoulders << body.shoulders << body.shouldersR << "           - - - -\n";
    else if(letAmount == 3)
        cout << "\t\t       " << (char)179 << "           " << body.shouldersL << body.shoulders << body.shoulders << body.shouldersM << body.shoulders << body.shoulders << body.shouldersR << "           - - -\n";
    cout << "\t\t       " << (char)179 << "           " << body.arm1 << "  " << body.body << "  " << body.arm2 << "    \n";
    cout << "\t\t       " << (char)179 << "           " << body.arm1 << "  " << body.body << "  " << body.arm2 << "            Letters Guess:\n";
    cout << "\t\t       " << (char)179 << "              " << body.body << " \n";
    cout << "\t\t       " << (char)179 << "            " << body.hipsL << body.hips << body.hipsM << body.hips << body.hipsR << "             " << letGuessed[0] << " " << letGuessed[1] << " " << letGuessed[2] << " " << letGuessed[3] << " " << letGuessed[4] << " " << letGuessed[5] << " " << letGuessed[6] << " " << letGuessed[7] << "\n";
    cout << "\t\t       " << (char)179 << "            " << body.leg1 << "   " << body.leg2 << "             " << letGuessed[8] << " " << letGuessed[9] << " " << letGuessed[10] << " " << letGuessed[11] << " " << letGuessed[12] << " " << letGuessed[13] << " " << letGuessed[14] << " " << letGuessed[15] << "\n";
    cout << "\t\t       " << (char)179 << "            " << body.leg1 << "   " << body.leg2 << "             " << letGuessed[16] << " " << letGuessed[17] << " " << letGuessed[18] << " " << letGuessed[19] << " " << letGuessed[20] << " " << letGuessed[21] << " " << letGuessed[22] << " " << letGuessed[23] << "\n";
    cout << "\t\t       " << (char)179 << "                              " << letGuessed[24] << " " << letGuessed[25] << " " << letGuessed[26] << "\n";
    cout << "\t\t" << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)193 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << (char)196 << "\n";
    cout << endl;
}

Dictionary.h
CODE
#ifndef Dictionary_h
#define Dictionary_h

#include <string>

#include "Word.h"

using namespace std;

class Dictionary
{

public:

    //C++ virtual function is a member function of a class.
    //A virtual function is declared with virtual keyword, and it
    //usually has a different functionality in the derived class.
    //A function call is resolved at run-time (dynamic binding)
    //Virtual functions are used to have a different functionality in the derived class.

    virtual void addWord();    

    virtual void deleteWord();

    virtual void findWord();

    virtual void getWord();

    string words;

    Word myWord;

  
    
};
#endif

Dictionary.cpp
CODE
#include "Dictionary.h"



void Dictionary::addWord(int MAX_WORD_SIZE, int Count, string Word, int Size, int Words)
{
    {
    myGame.loadFile();
    ofstream Datfile("words.txt");
    try
    {
    cout << "\tEnter a new word, keep it below " << MAX_WORD_SIZE << " characters: ";
    cin >> Word;
         Size  = strlen(Word);
    if(Size == 0 || Size > MAX_WORD_SIZE)
        throw Word;

          strcpy_s(Words[Count++],MAX_WORD_SIZE,Word);

          for (int i = 0; i < Count; ++i)
             Datfile << Words[i] << endl;
    }
    catch (int word)
    {
        cout << "An error was found incorrect key entered\n";
    }
    }
}


void Dictionary::deleteWord()
{
    //
}


void Dictionary::findWord()
{
    //
}


void Dictionary::getWord(string skipWord, char hmWord[], int &letAmount)
{
    ifstream fin; // A fstream is created and it's called "fin", like "cin".
    int randNum;  // local variable that will be used to randomize which word
                  // gets pick.

    srand( GetTickCount() ); // seeds are randomizer

    randNum = rand()%11; // assigns "randNum" to a random number 0 - 11

    while( (randNum < 1) || (randNum > 10) ) // This for loop makes sure that "randNuM"
        randNum = rand()%11;                 // stay's between 1 - 10

    fin.open("words.txt"); // open's up "words.txt"

    for(int i = 0; i < randNum; i++) // a for loop that reads through the words list
    {                                 // and skips over the words that aren't in the location of
        fin >> skipWord;             // where are "randNum" stops at.
    }

    fin >> hmWord; // reads in the random word and stores in "hmWord[]"

    fin.close(); // closes file
    fin.clear(); // clears flags used

    letAmount = strlen(hmWord);
}


Menu.h
CODE
// Definition of base class (Main.h)

#ifndef MENU_H
#define MENU_H

#include <iostream>

using namespace std;

class Menu
{

public:
    void displayTitle();
    // Function to output the name of the game
    // Postcondition: Outputs
    //                  Welcome to Hangman!
    void displayHeader();
    // Function to output the header of the game
    // Postcondition: Outputs
    //                  Please follow the instructions...
    void displayMenu();
    // Function to output the menu of the game
    // Postcondition: Outputs
    //*****************************************************************
    //*       M E N U       *
    //*       Type 'q' to Quit *
    //*****************************************************************
    //    (a)dd a word
    //    (d)elete a word
    //    (l)ist all word
    //    (s)earch for a word
    //    (p)lay game
    //*****************************************************************
    void displayChoice();
    // Function to output a message to the user asking for a choice.
    // Postcondition: Outputs
    //                  Please enter your choice:
    char getChoice();
    // Accessor method (or getter)
    void setChoice(char sel);
    // Mutator method (or setter)
    
protected:
    char choice; // Variable to store choice given by user
};

#endif // Matches the define above

Menu.cpp
CODE
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include "Controller.h"
#include "Dictionary.h"
#include "Game.h"
#include "HangmanGame.h"
#include "HangmanMenu.h"
#include "Menu.h"
#include "Word.h"


using namespace std;

int main ()
{
    Hangmanmenu hman = Hangmanmenu();
    Menu hmenu = Menu();
    
    Game game1("Alex");
    Game game2; //Used to demonstrate overloading operator

    string word;
    char inChar;

    hmenu.displayTitle(); // Call to display title
    hmenu.displayMenu(); // Call to display menu
    
    cout << "Today's player name: " << game1 << endl; //Overloading operator example
    cout << "Enter a different name: ";
    cin >> game2;
    cout << endl;
    cout << "Now the player is " << game1 << endl; // End of example

    hmenu.displayChoice(); //Call to ask user for a choice
    cin >> inChar;
    hmenu.setChoice(inChar);
    
    
    Controller myController;
    myController.Start();

    return 0;
}

Word.h
CODE
#ifndef Word_h
#define Word_h

#include "Dictionary.h"


class Word: public Dictionary
{

public:

    Dictionary myDictionary;
    

};
#endif

Word.cpp
CODE
#include "Word.h" //Word.cpp


HangmanMenu.h
CODE
// Definition of derived class (Hangmanmenu.h)

#include "Menu.h"
#include "Dictionary.h"

class Hangmanmenu : public Menu
{
private:
    Dictionary dictionary;
public:
    void displayMenu();

    // Overrides the function displayMenu() of the base class
    // Postcondition: First, the user is requested to press a key to continue.
    //                  Then, the screen is cleared.
    //                  Finally, it displays the menu of the game.
};

HangmanMenu.cpp
CODE
// Implementation for derived class (Hangmanmenu.h)

#include <iostream>
#include "HangmanMenu.h"
#include "Dictionary.h"

using namespace std;

void Hangmanmenu::displayMenu()
    {
        system("pause"); // Gives user some time to see the results
        system("cls"); // Clear screen
        Menu::displayMenu(); // Calls displayMenu function from base class
        // Postcondition: See definition in Menu.h
    }



Main.cpp
CODE

//
//Author: Nicholas Thomson
//Date of last change: 2 October 2008
//
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include "Controller.h"
#include "Dictionary.h"
#include "Game.h"
#include "HangmanGame.h"
#include "HangmanMenu.h"
#include "Menu.h"
#include "Word.h"


using namespace std;

int main ()
{
    Hangmanmenu hman = Hangmanmenu();
    Menu hmenu = Menu();
    
    Game game1("Alex");
    Game game2; //Used to demonstrate overloading operator

    string word;
    char inChar;

    hmenu.displayTitle(); // Call to display title
    hmenu.displayMenu(); // Call to display menu
    
    cout << "Today's player name: " << game1 << endl; //Overloading operator example
    cout << "Enter a different name: ";
    cin >> game2;
    cout << endl;
    cout << "Now the player is " << game1 << endl; // End of example

    hmenu.displayChoice(); //Call to ask user for a choice
    cin >> inChar;
    hmenu.setChoice(inChar);
    
    
    Controller myController;
    myController.Start();

    return 0;
}


This post has been edited by Thomsoningreen: 3 Oct, 2008 - 02:34 AM


Attached File(s)
Attached File  words.txt ( 5bytes ) Number of downloads: 7
User is offlineProfile CardPM
+Quote Post

OliveOyl3471
RE: Hangman Game Project
2 Oct, 2008 - 08:17 PM
Post #2

It's all about the code ♥
Group Icon

Joined: 11 Jul, 2007
Posts: 1,636



Thanked: 18 times
Dream Kudos: 150
My Contributions
Could you narrow it down a bit? That's a lot of code there. Do you know about where the errors are occurring? And what errors are you getting? Please be more specific and I'm sure someone will be able to help you with this.
smile.gif

This post has been edited by OliveOyl3471: 2 Oct, 2008 - 08:18 PM
User is offlineProfile CardPM
+Quote Post

Psionics
RE: Hangman Game Project
2 Oct, 2008 - 10:07 PM
Post #3

D.I.C Head
Group Icon

Joined: 6 Sep, 2008
Posts: 122



Thanked: 2 times
Dream Kudos: 100
My Contributions
Dude did you just write all that code without building your solution once? Ha! Here's what I can tell just from looking at it:

** first, you have several variables that are out of scope - letGuessed, alpha, hmLetters, letGuessed - inside your Game.cpp. I didn't have a lot of time right now so I didn't even bother searching outside of your Game.h, but I couldn't even find where you made those. However, since they don't seem to be in your Game.h or Game.cpp, either you need to include a different file, or you need to declare those somewhere


** secondly, in Game.cpp, you wrote the code Game::play and having it returning a value, but you made it a void function (not returning a value)


** next, in Menu.cpp and Main.cpp, you wrote the code Controller::Start without sending it parameters


This is really just the beginning of your errors, but you should fix the easy obvious ones first, then post what errors your having, and only the needed files/functions where the errors are happening. Try to paste only what someone needs so they can paste it into their compiler and see what's up.

Hope it helps smile.gif

User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: Hangman Game Project
2 Oct, 2008 - 10:43 PM
Post #4

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,025



Thanked: 35 times
Dream Kudos: 125
My Contributions
Yes, you are missing the owner of this project. biggrin.gif

alright, will you please post some of the errors you got? that will help us to resolve them.
It is a big code and it will be very difficult to find errors, so if you post what you are stuck on, it will be lot easier for us.

User is online!Profile CardPM
+Quote Post

Thomsoningreen
RE: Hangman Game Project
3 Oct, 2008 - 02:38 AM
Post #5

New D.I.C Head
*

Joined: 28 Sep, 2008
Posts: 5


My Contributions
This is the compiler output I got that list all of my errors. See if that helps you out some. I made sure to write out my author info in my first post as well.


CODE

1>------ Build started: Project: NicholasThomsonhangman, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>Word.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Dictionary.h(31) : error C2146: syntax error : missing ';' before identifier 'myWord'
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Dictionary.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Dictionary.h(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Main.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(8) : error C2504: 'Dictionary' : base class undefined
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C2146: syntax error : missing ';' before identifier 'myDictionary'
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\Main.cpp(25) : error C2664: 'Game::Game(const Game &)' : cannot convert parameter 1 from 'const char [5]' to 'const Game &'
1>        Reason: cannot convert from 'const char [5]' to 'const Game'
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>.\Main.cpp(46) : error C2660: 'Controller::Start' : function does not take 0 arguments
1>HangmanMenu.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(8) : error C2504: 'Dictionary' : base class undefined
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C2146: syntax error : missing ';' before identifier 'myDictionary'
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>HangmanGame.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\HangmanGame.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\HangmanGame.cpp(16) : error C2511: 'void HangmanGame::showHangMan(BODY &,int)' : overloaded member function not found in 'HangmanGame'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(9) : see declaration of 'HangmanGame'
1>.\HangmanGame.cpp(85) : error C2511: 'void HangmanGame::showScreen(BODY,std::string,char [],char [],int,int)' : overloaded member function not found in 'HangmanGame'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(9) : see declaration of 'HangmanGame'
1>Game.cpp
1>.\Game.cpp(32) : error C2065: 'alpha' : undeclared identifier
1>.\Game.cpp(38) : error C2065: 'letGuessed' : undeclared identifier
1>.\Game.cpp(41) : error C2065: 'hmLetters' : undeclared identifier
1>.\Game.cpp(57) : error C2065: 'alpha' : undeclared identifier
1>.\Game.cpp(57) : error C2039: 'alpha' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(20) : see declaration of 'Game'
1>.\Game.cpp(60) : error C2065: 'letGuessed' : undeclared identifier
1>.\Game.cpp(60) : error C2039: 'letGuessed' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(20) : see declaration of 'Game'
1>.\Game.cpp(63) : error C2065: 'hmLetters' : undeclared identifier
1>.\Game.cpp(63) : error C2039: 'hmLetters' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(20) : see declaration of 'Game'
1>.\Game.cpp(79) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(27) : see declaration of 'Game::play'
1>.\Game.cpp(88) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(27) : see declaration of 'Game::play'
1>.\Game.cpp(98) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(27) : see declaration of 'Game::play'
1>Dictionary.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(8) : error C2504: 'Dictionary' : base class undefined
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C2146: syntax error : missing ';' before identifier 'myDictionary'
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\Dictionary.cpp(6) : error C2511: 'void Dictionary::addWord(int,int,std::string,int,int)' : overloaded member function not found in 'Dictionary'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Dictionary.h(11) : see declaration of 'Dictionary'
1>.\Dictionary.cpp(44) : error C2511: 'void Dictionary::getWord(std::string,char,int &)' : overloaded member function not found in 'Dictionary'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Dictionary.h(11) : see declaration of 'Dictionary'
1>Controller.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(8) : error C2504: 'Dictionary' : base class undefined
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C2146: syntax error : missing ';' before identifier 'myDictionary'
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Word.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Build log was saved at "file://c:\Documents and Settings\Nicholas\My Documents\Visual Studio 2008\Projects\NicholasThomsonHangman\NicholasThomsonhangman\Release\BuildLog.htm"
1>NicholasThomsonhangman - 40 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: Hangman Game Project
3 Oct, 2008 - 03:22 AM
Post #6

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,025



Thanked: 35 times
Dream Kudos: 125
My Contributions
Well, first thing that I found when I saw the error was :
You have included Word.h in Dictionary.h and you also have object of Word class as member of Dictionary class. Then you have Word.h where you included Dictionary.h and you made it base class of Word class!!! plus you have Dictionary's object as member of it!!! This will surely not compile. So I guess All errors related to Dictionary class might be because of this.

Now errors in Hangman.cpp
Your functions in this file has parameters, whereas in Hangman.h you have parameterless methods as members! make sure the signatures of these methods are same.

Errors in Game.cpp
There are many variable you used in this file's methods which are not declared as members of your Game class or local variables. make sure that these variables are declared at proper place.
Seems that you wrote a function inside your Play function and that function is returning bool, but as you ended function definition with a semicolon, compiler thinks that Play function is returning something but Play is a void returning function! so this error is there. Make sure that you take that inner function "guessLet" out of your Play function. and put actual logic required for your play function.

Errors in Dictionary.cpp
same error that you have for Hangman.cpp, your function definitions in Dictionary.h does not match with what you wrote in .cpp make sure that these prototypes are same.

All other errors are because of that first problem I pointed out. See how you can resolve it. You can not have derived class object as member of base class.

I hope this will help you. smile.gif
User is online!Profile CardPM
+Quote Post

Thomsoningreen
RE: Hangman Game Project
5 Oct, 2008 - 12:54 PM
Post #7

New D.I.C Head
*

Joined: 28 Sep, 2008
Posts: 5


My Contributions
Well I have the whole projected zipped, it's in Visual Studios format. Thats the compiler I use. Anyways I got it down to 23 errors.
CODE
1>------ Build started: Project: NicholasThomsonhangman, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>Main.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\Main.cpp(25) : error C2664: 'Game::Game(const Game &)' : cannot convert parameter 1 from 'const char [5]' to 'const Game &'
1>        Reason: cannot convert from 'const char [5]' to 'const Game'
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>.\Main.cpp(46) : error C2144: syntax error : 'char' should be preceded by ')'
1>.\Main.cpp(46) : error C2660: 'Controller::Start' : function does not take 0 arguments
1>.\Main.cpp(46) : error C2059: syntax error : ')'
1>HangmanGame.cpp
1>c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\HangmanGame.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\HangmanGame.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\HangmanGame.cpp(12) : error C2144: syntax error : 'char' should be preceded by ')'
1>.\HangmanGame.cpp(12) : error C2660: 'Game::play' : function does not take 0 arguments
1>.\HangmanGame.cpp(12) : error C2059: syntax error : ')'
1>Game.cpp
1>.\Game.cpp(39) : error C2109: subscript requires array or pointer type
1>.\Game.cpp(58) : error C2039: 'alpha' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(21) : see declaration of 'Game'
1>.\Game.cpp(61) : error C2039: 'letGuessed' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(21) : see declaration of 'Game'
1>.\Game.cpp(64) : error C2039: 'hmLetters' : is not a member of 'Game'
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(21) : see declaration of 'Game'
1>.\Game.cpp(80) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(28) : see declaration of 'Game::play'
1>.\Game.cpp(89) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(28) : see declaration of 'Game::play'
1>.\Game.cpp(99) : error C2562: 'Game::play' : 'void' function returning a value
1>        c:\documents and settings\nicholas\my documents\visual studio 2008\projects\nicholasthomsonhangman\nicholasthomsonhangman\Game.h(28) : see declaration of 'Game::play'
1>Dictionary.cpp
1>.\Dictionary.cpp(12) : error C2065: 'myGame' : undeclared identifier
1>.\Dictionary.cpp(12) : error C2228: left of '.loadFile' must have class/struct/union
1>        type is &#