My Bulls and Cow games, with word length selection (3.5 KB)

Err, enjoy? Let me know what you think about my word length selection. I half-cheeked it last minute, which is never a good programing practice.

1 Like

I would put SetDifficulty() in a loop, so that the user can choose again if they entered an invalid word length. Other then that, I had fun guessing the words.

also we can use recursion call here:

        //check user input for valid characters & valid available word length
    	if (UserInput.find_first_not_of("0123456789") == FString::npos && 
    		stoi(UserInput) > MIN_WORD_LENGTH && stoi(UserInput) < MAX_WORD_LENGTH)
    	{// if input is valid set a hidden word with users length
    	{// if user input is invalid, suggest him to try again
    		std::cout << "Your input is not valid or ";
    		std::cout << "the length of the word you entered is not available.\nPlease try again\n\n";
    		AskWordLength(); //Here you call your function again

Privacy & Terms