Exemplo n.º 1
0
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();
	}
}
Exemplo n.º 2
0
// 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;



}
Exemplo n.º 3
0
//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;
}
Exemplo n.º 4
0
// 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;
}
Exemplo n.º 5
0
//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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
// 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;
}
Exemplo n.º 8
0
// 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;
}
Exemplo n.º 9
0
void PrintIntro()
{
    //introduction
    std::cout << "\nWelcome to Bulls and Cows, a fun word game\n";
    std::cout << "Can you guess the " << BCGame.GetHiddenWordLength();
    std::cout << " letter isogram I'm thinking of?\n";
    std::cout << std::endl;
    return;
}
Exemplo n.º 10
0
void PrintIntro() 
{
	int32 WORD_LENGTH = BCGame.GetHiddenWordLength();
	std::cout << "\n\n|||||/--------------------------------------------------------------\\|||||\n";
	std::cout << "||||/----------------------------------------------------------------\\||||\n";
	std::cout << "|||||     Welcome to Bulls and Cows, a fun word game.                |||||\n";
	std::cout << "|||||     Can you get the " << WORD_LENGTH << " letter isogram that I'm thinking of?     |||||\n";
	std::cout << "||||\\----------------------------------------------------------------/||||\n";
	std::cout << "|||||\\--------------------------------------------------------------/|||||\n\n";
	return;
}
Exemplo n.º 11
0
//declaration of function PrintIntro
void PrintIntro()
{
	//introduce the game
	int32 WORD_LENGTH = BCGame.GetHiddenWordLength();
	std::cout << "Welcome to Bulls and Cows :) ";
	std::cout << std::endl;
	std::cout << "Can you guess this " << WORD_LENGTH << " letter word, i'm thinking of?\n";
	std::cout << std::endl;

	return;
}
Exemplo n.º 12
0
void PrintIntro()
{
	std::cout << "Welcome to Bulls and Cows, a fun word game.\n";
	std::cout << std::endl;
	std::cout << "          }   {         ___ " << std::endl;
	std::cout << "          (o o)        (o o) " << std::endl;
	std::cout << "   /-------\\ /          \\ /-------\\ " << std::endl;
	std::cout << "  / | BULL |O            O| COW  | \\ " << std::endl;
	std::cout << " *  |-,--- |              |------|  * " << std::endl;
	std::cout << "    ^      ^              ^      ^ " << std::endl;
	std::cout << "Can you guess the " << BCGame.GetHiddenWordLength();
	std::cout << " letter isogram I'm thinking of?\n";
	std::cout << std::endl;
	return;
}
Exemplo n.º 13
0
void PrintIntro() {
	// introduce the game
	std::cout << "\n\nWelcome to Bulls and Cows\n";

	std::cout << "                   ________________________     \n";
 	std::cout << "          (__)    |                        |    \n";         
	std::cout << "          (oo)    |  Bulls    &     Cows!  |   \n";
	std::cout << "   /-------00  --'|________________________|    \n";
	std::cout << "  / |     ||                                    \n";
	std::cout << " *  ||----||                                    \n";
	std::cout << "    ^^    ^^ \n\n";

	std::cout << "Can you guess the " << BCGame.GetHiddenWordLength();
	std::cout << " letter isogram I'm thinking of?\n\n";
	return;
}
Exemplo n.º 14
0
//get Valid guess from user
FText GetValidGuess() 
{	
	FText Guess = "";
	EGuessStatus Status = EGuessStatus::Invalid_Status;

	do {
	//get a guess from player
	int32 CurrentTry = BCGame.GetCurrentTry();
	std::cout << "Try " << CurrentTry <<" of " <<BCGame.GetMaxTries() << ".Enter your Guess:";
	std::getline(std::cin, Guess);

	//checking if the guess is valid
	Status = BCGame.IsGuessValid(Guess);
	
	

		switch (Status)
		{
		case EGuessStatus::Not_Isogram:
			std::cout << "Please Enter a word without repeating letters !" << std::endl;
			break;
		case EGuessStatus::Lower_Case:
			std::cout << "Please Enter all lower case letters !" << std::endl;
			break;
		case EGuessStatus::Wrong_Lenght:
			std::cout << "Please Enter a " << BCGame.GetHiddenWordLength() << " letter Word !" << std::endl;
			break;
		default:
			//Assume that the status is OK
			break;
		}
		std::cout << std::endl;

	} while (Status != EGuessStatus::OK); //keep looping until we get no errors or we get Status == OK
	return Guess;

}
Exemplo n.º 15
0
// Introduce the game
void PrintIntro() {
    std::cout << "Welcome to Bulls and Cows\n";
    std::cout << "Can you guess the " << BCGame.GetHiddenWordLength();
    std::cout << " letter isogram I'm thinking of?\n";
    return;
}