Skip to content
Permalink
76f84e8963
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
71 lines (60 sloc) 1.41 KB
#include "alphabet.h"
using namespace std;
const int alpha_max = 26;
string answer;
void sortstring(string &str)
{
int charCount[alpha_max] = { 0 };
for (int index = 0;index < str.length();index++)
charCount[str[index] - 'a']++;
for (int index = 0;index < alpha_max;index++)
for (int j = 0;j < charCount[index];j++)
{
char c = ('a' + index);
answer += c;
}
}
void Alphabet :: random_word()
{
cout << "To earn money type the letters of the following word in alphabetical order: " << endl;
string word_list[] =
{ "confinement",
"penitentiary",
"reformatory",
"guardhouse",
"punishment",
"conviction",
"imprisonment",
"incarceration",
"sentencing",
"criminology" };
int word_index = rand() % 11;
string word = word_list[word_index];
cout << word << endl;
sortstring(word);
}
void check(string &userin)
{
JobMenu j;
PlayerMenu playermenu;
Sql sql;
if (answer == userin)
{
cout << "Well done! You have completed all of the laundry. 5 pounds has been added to your account." << endl;
sql.updateBalanceCleaningTable();
Sleep(2000);
playermenu.ppmenu();
}
else if (answer != userin)
{
cout << "Oh no! You have turned all of your inmates clothes pink! This will be deducted from your wages." << endl;
j.jobmenu();
}
}
void Alphabet :: user_input()
{
string userin;
cout << "Write the letters of this word in alphabetical order:" << endl;;
cin >> userin;
check(userin);
}