本文整理汇总了C++中FBullCowGame类的典型用法代码示例。如果您正苦于以下问题:C++ FBullCowGame类的具体用法?C++ FBullCowGame怎么用?C++ FBullCowGame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FBullCowGame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayGame
void PlayGame(){
int32 MaxTries = BCGame.GetMaxTries();
std::cout << MaxTries << std::endl;
//BCGame() = FBullCowGame();
// loop for the number of turns asking for entries
//constexpr int NUMBER_OF_TURNS = 5;
//TODO: Change from For to a While loop once we are validating tries
while (BCGame.IsGameWon()==false && BCGame.GetCurrentTry() <= MaxTries) {
//std::cout<< "Status of Game is : " <<BCGame.IsGameWon() << "\n\n";
//for (int32 count = 1; count <= MaxTries; count++) {
FText Guess = GetValidGuess();
//TODO: Make check for valid guesses.
// Submit valid guess to the game
FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
// Print number of bulls and cows
std::cout << "Bulls = " << BullCowCount.Bulls << " \n";
std::cout << "Cows = " << BullCowCount.Cows << " \n";
std::cout << "You entered >> " << Guess << " <<, thank you, let me check.\n";
std::cout << std::endl;
//std::cout<< "Status of Game is : inside FOR Loop " <<BCGame.IsGameWon() << "\n\n";
}
PrintGameSummary();
return; //TODO: HELLO
}
示例2: PlayGame
//play the game
void PlayGame()
{
BCGame.Reset();
int32 MaxTries = BCGame.GetMaxTries();
//loop asking for guess while
//game is NOT won and their are still tries remainging
while(!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries)
{
FText Guess = GetValidGuess();
//submit a valid guess to game
FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
std::cout << "Bull = " << BullCowCount.Bulls;
std::cout << ". Cows = " << BullCowCount.Cows;
std::cout << std::endl;
}
PrintGameSummary();
return;
}
示例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
// 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: GetGuess
// loop continually until user gives a valid guess.
FText GetGuess()
{
FText InString;
EGuessStatus Status = EGuessStatus::Invalid_Status;
int32 CurrentTry = BCGame.GetCurrentTry();
do
{
std::cout << "Try #" << CurrentTry << "/" << BCGame.GetMaxTries() << " Enter your guess: ";
getline(std::cin, InString);
Status = BCGame.GuessValid(InString);
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 ensure that your input is all lowercase letters.\n\n";
break;
default:
return InString;
}
} while (Status != EGuessStatus::OK);
return InString;
}
示例8: 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;
}
示例9: SetDifficulty
void SetDifficulty()
{
FText InString;
getline(std::cin, InString);
try
{
int Level = std::stoi(InString);
if (Level < 1 || Level > 5)
{
std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: ";
SetDifficulty();
}
else
{
BCGame.SetDifficulty(Level);
std::cout << std::endl << "Alright, we're working with a " << BCGame.GetHiddenWordLength() << " letter isogram. Let's play the game!\n\n";
}
}
catch (std::invalid_argument& e)
{
std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: ";
SetDifficulty();
}
catch (std::out_of_range& e)
{
std::cout << "\nPlease be sure to enter a valid integer between 1 and 5: ";
SetDifficulty();
}
}
示例10: PlayGame
void PlayGame()
{
int32 MaxTries = BCGame.GetMaxTries();
// Get a guess from the player and repeat it back to them.
while(!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries)
{
FText Input = GetGuess();
FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Input);
std::cout << "Number of Bulls: " << BullCowCount.Bulls << std::endl;
std::cout << "Number of Cows: " << BullCowCount.Cows << std::endl << std::endl;
}
PrintGameSummary(BCGame.IsGameWon());
return;
}
示例11: PlayGame
// Plays a single game to completion
void PlayGame()
{
BCGame.Reset();
int32 MaxTries = BCGame.GetMaxTries();
//Loop asking for guesses while the game is NOT won and there are still turns
while (!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries)
{
FText Guess = GetValidGuess();
FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
std::cout << "Bulls = " << BullCowCount.Bulls;
std::cout << ", Cows = " << BullCowCount.Cows << "\n\n";
}
PrintGameSummary();
}
示例12: GetGuess
// Get a guess from the player
FText GetGuess() {
FText Guess = "";
std::cout << BCGame.GetCurrentTry() << ". Make a guess: ";
//BCGame.IncTry();
getline(std::cin, Guess);
return Guess;
}
示例13: PrintIntro
// Introduce the game
void PrintIntro(){
std::cout << ("\n\nHELLO\n");
std::cout << ("This is using namespace identifiers\n");
std::cout << ("Welcome to Bull and Cows a Fun Game\n");
std::cout << "Can you guess the "<< BCGame.GetHiddenWordLength() <<" letter isogram I'm thinking of?\n";
return;
}
示例14: GetGuess
FText GetGuess()
{
FText Guess = "";
std::cout << "Try " << BCGame.GetCurrentTry() << ": Enter your guess: ";
std::getline(std::cin, Guess);
return Guess;
}
示例15: PrintGameSummary
void PrintGameSummary(){
if (BCGame.IsGameWon()){
std::cout << "Well Done - YOU WIN!\n";
}
else{
std::cout << "Better luck next time !\n";
}
}