-
void ChangeToUpper( string & phrase) {
int i;
for(i=0; i < phrase.size(); i++) {
phrase[i] = toupper(phrase[i]);
}
return;
}
-
bool ValidName(string name) {
bool isValid = false;
ChangeToUppper(name);
// i don't like this, but I want it to fit on the screen
if (("MERCURY" == name) or ("VENUS" == name) or ("EARTH") == name)
or ("MOON" == name) or ("MARS" == name ) or ("JUPITER" == name)
or ("SATURN" == name) or ("NEPTUNE" == name ) or ("URANUS" == name)
or ("PLUTO" == name)) {
isValid = true;
}
return isValid;
}
-
void PlayAsGuesser() {
int low = LOW_VALUE,
high = HIGH_VALUE;
bool found = false;
int guess;
int result;
while (not found and low <= high) {
guess = NextGuess(low, high);
result = DoGuess(guess);
switch (result) {
case RIGHT:
found = true;
break;
case LOW:
low = guess+1;
break;
case HIGH:
high = guess-1;
break;
}
}
PrintWin();
return;
}