1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
PROGRAM NAME: Word Jumble
PROGRAM PURPOSE: The Classic word jumble game where the player can ask for a hint
PROGRAMMER: Thomas Gallagher
DATE WRITTEN: 10-11-14
*/
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
//____________________________________________________________________________________________________________________________________
int main()
{
enum fields { WORD, HINT, NUM_FIELDS };
const int NUM_WORDS = 5;
const string WORDS[NUM_WORDS][NUM_FIELDS] =
{
{ "wall", "Do you feel you're head banging against something?" },
{ "glasses", "These might help you see the answer." },
{ "insane", " doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." },
{ "persistent", "Keep at it!" },
{ "Love", "Who do you Like?" }
};
//__________________________________________________________________________________________________________________
enum difficulty { EASY, MEDIUM, HARD, NUM_DIFF_LEVELS };
cout << "There are " << NUM_DIFF_LEVELS << " Difficulty levels.\n";
//__________________________________________________________________________________________________________________
srand(static_cast<unsigned int>(time(0)));
int choice = (rand() % NUM_WORDS);
string TheWord = WORDS[choice][WORD];
//word to guess
string TheHint = WORDS[choice][HINT];
//hint for word
string jumble = TheWord;
//jumble version of word
int length = jumble.size();
for (int i = 0; length; ++i)
{
int index1 = (rand() % length);
int index2 = (rand() % length);
char temp = jumble[index1];
jumble[index2] = temp;
}
//__________________________________________________________________________________________________________________
cout << "\t\t\tWelcome to the Word Jumble Game!\n\n";
cout << "Unscramble the letters to make a word.\n";
cout << "Enter 'hint' for a hint.\n";
cout << "Enter 'quit' to quit the game.\n\n";
cout << "The jumble is: " << jumble;
string guess;
cout << "\n\nYour guess is: ";
cin >> guess;
while ((guess != TheWord) && (guess != "quit"))
{
if (guess == "hint")
{
cout << TheHint;
}
else
{
cout << "Sorry that's, not it.";
}
//__________________________________________________________________________________________________________________
cout << "\n\nYour guess is: ";
cin >> guess;
if (guess == TheWord)
{
cout << "\nThats it, You Guessed it!\n";
}
cout << "\nThanks For Playing!\n";
}
//__________________________________________________________________________________________________________________
system("pause");
return 0;
}
|