//Word Jumble - The classic word jumble game where the play can ask for a hint #include #include #include #include using namespace std; int main(){ enum fields {WORD, HINT, NUM_FIELDS}; const int NUM_WORDS = 10; const string WORDS[NUM_WORDS][NUM_FIELDS]= { {"wall", "Do you feel you're banging your head against something?"}, {"glasses", "Wank too much, and you may need a pair."}, {"drugs", "They enhance the lols"}, {"persistant", "Keep at it. "}, {"jumble", "Its what the game is all about."}, {"laptop", "Portable computery goodness"}, {"banana", "The phallus like fuit"}, {"gonorrhea", "The STD that makes the world go around"}, {"fear", "JC is a haxor on it"}, {"god", "Smoko is the one and only"} }; cout << "\t\t\tWelcome to Word Jumble!\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"; int playing = 1; int tries = 1; int score = 0; while(playing){ srand(time(0)); int choice = (rand() % NUM_WORDS); string theWord = WORDS[choice][WORD]; //the word to guess string theHint = WORDS[choice][HINT]; //the hint for the word string jumble = theWord; //jumbled version of the word int length = jumble.size(); for(int i = 0; i < length; i++){ int index1 = (rand() % length); int index2 = (rand() % length); char temp = jumble[index1]; jumble[index1] = jumble[index2]; jumble[index2] = temp; } cout << "The jumble is: " << jumble; string guess; cout << "\n\nYour guess: "; cin >> guess; while((guess != theWord) && (guess != "quit")){ if(guess == "hint"){ cout << theHint; } else{ cout << "Sorry, that's not it."; tries++; } cout << "\n\nYour guess: "; cin >> guess; } if(guess == theWord){ cout << "\nYou guessed it!\n"; cout << "It took you " << tries << " to guess the word.\n\n"; score++; } if(guess == "quit"){ cout << "\n\nYour score for this round was " << score << "!\n"; cout << "Thanks for playing!\n"; cout << "Press any key to quit..."; playing = 0; } } cin.get(); cin.get(); return 0; }