Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Queries and Discussion > Programming > C-C++

Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More
 
Bookmarks Thread Tools Search this Thread Display Modes
Old 03-09-2010, 09:41 AM   #1
Newbie Member
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Serenity1194 is on a distinguished road

Hangman C++ code with so much errors. Please help,


Code:
#include<iostream>
#include<ctime>
#include<cctype>


const char dictionary [4][3][60] = {
                                        {"similarity", "advertiser", "bookkeeper"},
                                        {"encyclopedia", "transportation", "establishments"},
                                        {"sedimentation", "acquirement", "procurement"},
                                        {"zenzizenzizenzic", "antidisestablishmentarianism", "pneumonoultramicroscopicsilicovolcaniosis"}
                                     };
                                     
#define char cheat = "Crepe";
bool cheat_check = false, start_screen = true, guess;
int error_ctr = 0, diff_set, lim;
char store_array [60], out_array [60], name[20];
char ans, user_inp;


void GameMaster();
void Drawing(bool);
int RandNumGen();
void Environment(int);
void Input();
void Dictionary(int, char []);
bool GuessChecker ();

int main();
{
    int env_num;
    Drawing(start_screen);
    start_screen = false;
    system("pause");
    system("cls");
    GameMaster();
    env_num = RandNumGen();
    Environment(env_num);
    system("pause");
    return 0;
}

void GameMaster()
{
    cout<<"Welcome to Foot Noose, where we (ironically) hang you by the head, not the foot!"<<endl;
    cout<<"Now, how shall I call you?"<<endl;
    cin>>name;
    if (strcmp(name, "Crepe")==0)
    {
        cout<<"Excellent! Don't we all know that Crepe is tasty?"<<endl;
        system("cls");
        cheat_check = true;
    }
    cout<<"Hello, "<<name<<endl;
    system("cls");

    char difficulty;

    cout<<"The rules of Foot Noose are simple. The computer will pick a word, "<<endl<<"and you have a set number of tries to guess the word."<<endl;
    cout<<"You have to do this one letter at a time."<<endl<<endl;
    cout<<"There are four difficulty settings with which to play the game."<<endl;
    cout<<"Easy is a set of words with minimal complication, and lots of repeating letters."<<endl<<" So if you get the repeating letter correctly,"
        <<" you've taken a large part of the word."<<endl;
    cout<<"Medium is a step up from easy, with bigger words. No worries, because they're not that hard to guess."<<endl;
    cout<<"Hard is a good few steps from Medium, so as to live up to its name."<<endl<<" Scientific terms present in this difficulty."<<endl;
    cout<<"Extreme is a far cry from hard. If you get the word here, you must be really lucky, or really smart."<<endl<<" It wasn't named Extreme"
        <<" for nothing."<<endl;
    system("cls");
    cout<<"(E) for Easy, (M) for Medium, (H) for Hard, (X) for Extreme."<<endl;
    cout<<"How far will you dig your grave? Or for those who do not understand metaphors,"<<endl<<"What difficulty would you want?"<<endl;
    cin>>ans;

    switch (ans)
    {
        case 'E':
        case 'e':
            {
                diff_set = 1;
                lim = 4;
                break;
            }
        case 'M':
        case 'm':
            {
                diff_set = 2;
                lim = 6;
                break;
            }
        case 'H':
        case 'h':
            {
                diff_set = 3;
                lim = 9;
                break;
            }
        case 'X':
        case 'x':
            {
                diff_set = 4;
                lim = 12;
                break;
            }

    }

    Dictionary(diff_set, store_array []);

SavePoint1:

    Input();

    guess = GuessChecker();

    if (!guess)
    {
        error_ctr++;
        Drawing(start_screen);
        if (error_ctr < lim)
            goto SavePoint1;
    }
    else if (error_ctr == lim)
        Drawing(start_screen);    
    else
    {
        if (strcmp(store_array, out_array)==0)
            break;
        else
            goto SavePoint1;
    }
}

void Dictionary(diff, store [])
{
    int num1 = RandNumGen();
    for (int ctr = 0; dictionary[diff][num1][ctr]; ctr++)
        store[ctr] = dictionary[diff][num1][ctr];
}

void Input()
{
    char temp;

    cout<<"Now, choose one of the 26 letters of the alphabet."
    cin>>user_inp;

    while (!(isalpha(user_inp)))
    {
        cout<<"Not that letter. The letter which is actually part of our alphabet."<<endl;
        cin>>user_inp;
    }

    if (isupper(user_inp))
        temp = tolower(user_inp);

    user_inp = temp;
}

void Drawing(bool screen)
{
    int wid_len;
    wid_len = lim - error_ctr;
    if (screen)
    {
        cout<<" _______ _______ _______ _______     _______ _______ _______ _______ _______ "<<endl;
        cout<<"|\     /|\     /|\     /|\     /|   |\     /|\     /|\     /|\     /|\     /|"<<endl;
        cout<<"| +---+ | +---+ | +---+ | +---+ |   | +---+ | +---+ | +---+ | +---+ | +---+ |"<<endl;
        cout<<"| |   | | |   | | |   | | |   | |   | |   | | |   | | |   | | |   | | |   | |"<<endl;
        cout<<"| |F  | | |O  | | |O  | | |T  | |   | |N  | | |O  | | |O  | | |S  | | |E  | |"<<endl;
        cout<<"| +---+ | +---+ | +---+ | +---+ |   | +---+ | +---+ | +---+ | +---+ | +---+ |"<<endl;
        cout<<"|/_____\|/_____\|/_____\|/_____\|   |/_____\|/_____\|/_____\|/_____\|/_____\|"<<endl;
    }
    else if (error_ctr < lim)
    {
        cout<<" _____   "<<setw(wid_len)<<" ___ "<<endl;
        cout<<"|     |  "<<setw(wid_len)<<" | | "<<endl;
        cout<<"|        "<<setw(wid_len)<<"====="<<endl;
        cout<<"|        "<<setw(wid_len)<<"(>_<)"<<endl;
        cout<<"|        "<<setw(wid_len)<<" /|\\ "<<endl;
        cout<<"|_______ "<<setw(wid_len)<<"o | o"<<endl;
        cout<<"_______/|"<<setw(wid_len)<<" / \\ "<<endl;
        cout<<"|      | "<<setw(wid_len)<<"/   \\"<<endl;
        Sleep(1000);
        system("cls");
    }
    else if (error_ctr == lim)
    {
        cout<<" _____                            "<<endl;
        cout<<"|     |                            "<<endl;
        cout<<"|     0                            "<<endl;
        cout<<"|    /|\\                         "<<endl;
        cout<<"|    / \\                         "<<endl;
        cout<<"|_______                            "<<endl;
        cout<<"_______/|                        "<<endl;
        cout<<"|      |                            "<<endl;
        cout<<"                                    "<<endl;
        cout<<"@@@@@@@@   @@@@@@   @@@  @@@     "<<endl;
        cout<<"@@@@@@@@  @@@@@@@@  @@@  @@@     "<<endl;
        cout<<"@@!       @@!  @@@  @@!  @@!     "<<endl;
        cout<<"!@!       !@!  @!@  !@!  !@!     "<<endl;
        cout<<"@!!!:!    @!@!@!@!  !!@  @!!     "<<endl;
        cout<<"!!!!!:    !!!@!!!!  !!!  !!!     "<<endl;
        cout<<"!!:       !!:  !!!  !!:  !!:     "<<endl;
        cout<<":!:       :!:  !:!  :!:   :!:    "<<endl;
        cout<<" ::       ::   :::   ::   :: ::::"<<endl;
        cout<<" :         :   : :  :    : :: : :"<<endl;
        system("pause");
        system("cls");
    }
}

bool GuessChecker()
{
    int true_check = 0;
    for (int ctr = 0; store_array[ctr]; ctr++)
    {
        if (store_array[ctr] == user_inp)
        {
            out_array[ctr] = store_array[ctr];
            true_check++;
        }
    }

    if (true_check > 0)
        return true;
    else
        return false;
}

Last edited by shabbir; 03-09-2010 at 11:43 AM.. Reason: Code blocks
Serenity1194 is offline   Reply With Quote
Old 03-09-2010, 12:02 PM   #2
Mentor
 
Join Date: Aug 2004
Posts: 2,134
Thanks: 3
Thanked 77 Times in 67 Posts
Rep Power: 13
xpi0t0s is just really nicexpi0t0s is just really nicexpi0t0s is just really nicexpi0t0s is just really nicexpi0t0s is just really nice

Re: Hangman C++ code with so much errors. Please help,


What errors?
xpi0t0s is offline   Reply With Quote
Old 03-09-2010, 12:07 PM   #3
Newbie Member
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Serenity1194 is on a distinguished road

Re: Hangman C++ code with so much errors. Please help,


Ahh, I have fixed the problem. There was a semi-colon in main. There was also a function that I forgot to put. It's all good now. Thanks though.
Serenity1194 is offline   Reply With Quote
Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Bookmarks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

 

All times are GMT +5.5. The time now is 01:57 AM.