本文整理汇总了C++中FBullCowGame::CheckGuessValidity方法的典型用法代码示例。如果您正苦于以下问题:C++ FBullCowGame::CheckGuessValidity方法的具体用法?C++ FBullCowGame::CheckGuessValidity怎么用?C++ FBullCowGame::CheckGuessValidity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FBullCowGame
的用法示例。
在下文中一共展示了FBullCowGame::CheckGuessValidity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetValidGuess
// loop continually until the user gives a valid guess
FText GetValidGuess() {
FText Guess = "";
EGuessStatus Status = EGuessStatus::Invalid_Status;
do {
// get a guess from the player
int32 TryNumber = BCGame.GetCurrentTry();
std::cout << "Try " << TryNumber << " of " << BCGame.GetMaxTries();
std::cout << ". Enter your guess: ";
std::getline(std::cin, Guess);
Status = BCGame.CheckGuessValidity(Guess);
switch (Status){
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word. \n\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "Please enter a word without repeating letters.\n\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter all lowercase letters.\n\n";
break;
default:
break;
}
std::cout << std::endl;
} while (Status != EGuessStatus::OK); // keep looking until we get no errors
return Guess;
}
示例2: GetValidGuess
//get a guess from the user
FText GetValidGuess()
{
EGuessStatus Status = EGuessStatus::Invalid;
FText Guess = "";
do
{
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry << " of " << BCGame.GetMaxTries() << ". Enter your guess: ";
std::getline(std::cin, Guess);
Status = BCGame.CheckGuessValidity(Guess);
switch (Status)
{
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "Please enter a word without repeating letters.\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter the word using all lowercase letters.\n";
break;
default:
break; // Assume guess is valid
}
std::cout << std::endl;
} while (Status != EGuessStatus::OK); // keep looping until we get no errors
return Guess;
}
示例3: GetGuess
std::string GetGuess()
{
FText Guess = "";
EGuessStatus Status = EGuessStatus::Invalid;
do
{
int CurrentTry = BCGame.GetCurrentTry();
//get a guess from player
std::cout << "Try " << CurrentTry << " of " << BCGame.GetMaxTries();
std::cout << ". Enter your guess: ";
std::getline (std::cin, Guess);
Status = BCGame.CheckGuessValidity(Guess);
switch (Status)
{
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter a lowercase word.\n\n";
break;
case EGuessStatus::Not_Isogram:
std::cout <<"Please enter a word without repeating letters.\n\n";
break;
default:
break;
}
} while (Status != EGuessStatus::OK); //keep looping until we get valid input
return Guess;
}
示例4: GetValidGuess
//get the guess and print it back to you
FText GetValidGuess()
{
FText Guess;
EGuessStatus Status = EGuessStatus::Invalid_Status;
do {
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry++ << " of "<< BCGame.GetMaxTries()<<". Take a swag: ";
std::getline(std::cin, Guess);
Status = BCGame.CheckGuessValidity(Guess);
switch (Status) {
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "Make sure you have entered a word without repeating letters.\n\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter an all-lowercase word.\n\n";
break;
default:
//assume the guess is valid
break;
}
} while (Status != EGuessStatus::OK); //keep looping until we get no errors
return Guess;
}
示例5: GetValidGuess
// Get a guess from the player
FText GetValidGuess()
{
EGuessStatus Status = EGuessStatus::Invalid;
do
{
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try "<< CurrentTry << ": Enter your guess here: ";
FText GetGuessVal="";
std::getline(std::cin, GetGuessVal);
//CurrentTry++;
Status = BCGame.CheckGuessValidity(GetGuessVal);
switch (Status)
{
case EGuessStatus::Wrong_Length:
std::cout << "please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "please enter a word without repeating letters.\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "please enter a word in lower case.\n";
break;
default:
return GetGuessVal;
}
} while (Status != EGuessStatus::OK); //Keep looping until we get a valid entry
return 0;
}
示例6: PlayGame
void PlayGame(){
BCGame.Reset();
PrintIntro();
// Loop for the number of turns asking for guesses
for (int32 count = 1; count <= BCGame.GetMaxTries(); count++) {
FText guess = GetGuess();
EWordStatus status = BCGame.CheckGuessValidity(guess);
switch (status) {
case EWordStatus::OK: {
FBullCowCount bullCowCount = BCGame.SubmitGuess(guess);
// print the number of bulls and cows
std::cout << "Bulls " << bullCowCount.Bulls;
std::cout << " Cows " << bullCowCount.Cows;
std::cout << std::endl;
break;
}
case EWordStatus::Wrong_Length: {
std::cout << "Wrong length! Try again.\n";
break;
}
case EWordStatus::Not_Lowercase : {
std::cout << "Not Lowercase! Try again.\n";
break;
}
default: {
std::cout << "Not Valid! Try again.\n";
break;
}
}
if (status == EWordStatus::OK) {
}
}
return;
}