#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
// Functions
int instructions();
int game();
//Types and Arrays
string word[] = {"GOLDFISH", "COMPUTER", "ANONYMOUS", "JACKET", "SHARP", "SERVICE", "EFFORT", "CHARACTER", "CHANGE", "WITHOUT", "PRODUCT", "UNFOLDS", "MUSIC", "MOMENT", "LIFETIME", "PROVIDE"};
char guess[50];
char inst[50];
int main()
{
cout << "\tWelcome to Word Jumble By Khoanyneosr!\n";
cout << "\nWould you like to see the instructions?"
<< "\n\t1) Yes = 1"
<< "\n\t2) No = 2"
<< "\n- ";
cin.getline(inst, 50);
bool done = false;
do
{
switch(inst[50])
{
case 1:
instructions();
done = true;
break;
case 2:
cout << "\n\tGood luck!\n\n";
system("pause");
game();
done = true;
break;
default:
cout << "\n\nInvalid input. Try again\n- ";
cin.clear();
cin >> inst;
done = false;
continue;
}
}while (!done);
return 0;
}
int instructions()
{
system("cls");
cout << endl << endl << endl << "\tINSTRUCTIONS" << endl;
cout << endl << "1 - You will be presented with a word. Your job is to guess it." << endl;
cout << endl << "2 - At the beginning of the game your given 10 points." << endl;
cout << endl << "3 - You will be given 1 hint. Everytime you have to revisit\nthe hint 1 point will be deducted." << endl;
cout << endl << "4 - For everytime you guess wrong 1 point will be deducted." << endl;
cout << endl << "5 - When your point value reaches 0, the game is over." << endl;
cout << endl << "You can exit at anytime by pressing Q." << endl;
cout << endl << endl << "\tGood Luck!" << endl << endl << endl;
system("pause");
return game();
}
int game()
{
char guess[15];
system("cls");
srand(time(0));
std::string s = word[ rand() % 16 ];
std::cout << "\nOriginal word: " << s << '\n';
std::random_shuffle(s.begin(), s.end());
std::cout << "\nScrambled word: " << s << '\n';
cout << endl << "What is your guess?\n- ";
cin.get(guess, 0);
cout << guess[15] << endl;
return 0;
}
That's my code... Is there anyway that in the first switch statement i could use both Char values and int values? if i wanted the user to enter either 1 or a 2 and they enter a z or an f or something, i would like it to prompt them again... but i can't figure it out... Thanks