I have some issue with completing the final version of BCGame. Can someone help?

Okay, so I took a jab at the challenge and I came out with a lot of issues with my program. Perhaps I tried to implement too much, but it’s too late now. I can’t figure out how to solve these issues. Could someone help?

  1. I just came back to this tutorial after some time, actually, but when I left off I had this issue with running my program. For some reason the program just skipped over my print_intro() method. Which worked perfectly prior to implementing additional methods in my program like GetDifficulty(). Around the same time I got an alert message from Norton Security that it had stopped my program from executing. I don’t know if that’s the reason why print_intro() is being skipped over or not.

print_intro():
void print_intro()
{

//introducing the game

std::cout << "Welcome to the Bulls and Cows game!" << std::endl << std::endl;
std::cout << "In this game you will be required to guess an isogram that is of some ";
std::cout << " characters in length; however, you will only be alloted a limited number of ";
std::cout << "letter or word guesses, so chose wisely. Goodluck! I hope you have fun! :)\n";
std::cout << "{   }  {   }                          \n";
std::cout << " ---    ---                           \n";
std::cout << "  {     }                             \n";
std::cout << "------------   &   -------------      \n";
std::cout << "\\ (.)  (.) /       \\  (.)  (.) /    \n";
std::cout << " \\        /         \\         /     \n";
std::cout << "  \\      /           \\       /      \n";
std::cout << "   -=--=-              -=--=-         \n";
std::cout << "  / |   | \\          / |   |  \\     \n";
std::cout << " /  o   o  \\        /  o   o   \\    \n";
std::cout << "|           |-     |            |-    \n";
std::cout << "|     o     | |    |    (  )    |  |  \n";
std::cout << " -----------  |     -----------    |  \n";
std::cout << "    |   |     o        |   |       o  \n";
std::cout << "    o   o              o   o          \n";
std::cout << std::endl << std::endl;
FString i = "is";

//TODO modify game summary


//getting a guess from the player



return; 

}

//repeat the guess back to them

//loop continually until user gives valid guess
FText get_valid_guess(int32 rem_tries)
{
EGuessStatus Status = EGuessStatus::Guess_invalid;

do {
	//get guess from player
	
	FText Guess = "";

		std::cout << "Enter your guess here: ";

		std::getline(std::cin, Guess);
		
		EGuessStatus Status = BCGame.CheckGuessValidity(Guess);

		if (Status == EGuessStatus::Guess_valid)
		{
			 

			std::cout << "\n\nYou have " << rem_tries << " more tries.\n\n\n";
		}

	switch (Status)
	{
	case EGuessStatus::Guess_not_isogram:
		std::cout << "\nPlease enter an isogram. An isogram is a word without repeating ";
		std::cout << "characters:\ne.g. 'hemlock', or simply a single character.\n\n";
		break;

	case EGuessStatus::Guess_isogram_not_of_equal_length:
		std::cout << "\nPlease enter a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n ";
		break;

	case EGuessStatus::Guess_not_char_nor_equal_length_isogram:
		std::cout << "\nPlease enter a one letter character or a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n";
		break;

	case EGuessStatus::Guess_not_lowercase:
		std::cout << "\nPlease make sure your that your letter or isogram guesses are all lowercase.\n\n";
		break;

	default:
		return Guess;
	}

	std::cout << std::endl;


} while (Status != EGuessStatus::Guess_valid);
//keep looping till we get no errors

}

  1. But when It did skip over print_intro it ran my GetDifficulty() method which also contains an issue that I cannot solve. For some reason I can’t get out of the while loop in GetDifficulty(), and I can’t figure out why. I just reused the same code that I used earlier in my program, granted I didn’t really understand how it worked. Regardless I don’t know it’s not working. Is this appropriate logic?

void FBullCowGame::GetDifficulty() //***function GetDifficulty pb
{
std::cout << “Okay player, choose a difficulty so we can begin. You can either choose ‘1’ for EASY, ‘2’ for MEDIUM, or ‘3’ for HARD. Your chosen difficulty\n”;
std::cout << “will determine the length of your word as well as the maximum number of tries that you have.\n”;
std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
int32 intdifficulty;
FString confirm;

while (confirm[0] != 'y' || 'Y') 

{


	while (!(std::cin >> intdifficulty) || (intdifficulty > 3 && intdifficulty < 1))
	{

		std::cout << "\n\nThe difficulty you provide must be an integer number. e.g. '1 (EASY)'\n\n";
		std::cout << "Also the  difficulty has to be less than or equal to '3', but not less than 1. Try again. \n\n";
		std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
		std::cin.clear();
		std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


	}

	std::cin.clear();
	std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

	if (intdifficulty == 1)
	{
		std::cout << "Okay so you chose to play in 'EASY' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{

			Difficulty = 'e'; //EASY
		}
	}
	
	else if (intdifficulty == 2)
	{
		std::cout << "Okay so you chose to play in 'MEDIUM' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{
			Difficulty = 'm'; //MEDIUM
		}
	}

	else if (intdifficulty == 3)
	{
		std::cout << "Okay so you chose to play in 'HARD' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{
			Difficulty = 'h'; //HARD
		}
	}
  1. And now Visual Studio is giving me this error when I try to debug my solution.The system file cannot be specified: unable to start the program @ this file path:

C:\Users\sd476\Documents\Visual Studio 2015\Projects\Section_02b\Debug

What’s this error about? There are no files in the debug folder. Is this the appropriate path?

Entire Program:

#include
#include
#include “FBullCowGame.h”

using FText = std::string;

void print_intro();
FText get_valid_guess(int32 rem_tries);
void play_game();
bool ask_to_play_again();
void print_game_summary();

FBullCowGame BCGame;

int main()
{
bool bplay_again = false;

do {
	

	print_intro();

	play_game();

	bplay_again = ask_to_play_again();


	
} 

while (bplay_again);

return 0;

}

void print_intro()
{

//introducing the game

std::cout << "Welcome to the Bulls and Cows game!" << std::endl << std::endl;
std::cout << "In this game you will be required to guess an isogram that is of some ";
std::cout << " characters in length; however, you will only be alloted a limited number of ";
std::cout << "letter or word guesses, so chose wisely. Goodluck! I hope you have fun! :)\n";
std::cout << "{   }  {   }                          \n";
std::cout << " ---    ---                           \n";
std::cout << "  {     }                             \n";
std::cout << "------------   &   -------------      \n";
std::cout << "\\ (.)  (.) /       \\  (.)  (.) /    \n";
std::cout << " \\        /         \\         /     \n";
std::cout << "  \\      /           \\       /      \n";
std::cout << "   -=--=-              -=--=-         \n";
std::cout << "  / |   | \\          / |   |  \\     \n";
std::cout << " /  o   o  \\        /  o   o   \\    \n";
std::cout << "|           |-     |            |-    \n";
std::cout << "|     o     | |    |    (  )    |  |  \n";
std::cout << " -----------  |     -----------    |  \n";
std::cout << "    |   |     o        |   |       o  \n";
std::cout << "    o   o              o   o          \n";
std::cout << std::endl << std::endl;
FString i = "is";

//TODO modify game summary


//getting a guess from the player



return; 

}

//repeat the guess back to them

//loop continually until user gives valid guess
FText get_valid_guess(int32 rem_tries)
{
EGuessStatus Status = EGuessStatus::Guess_invalid;

do {
	//get guess from player
	
	FText Guess = "";

		std::cout << "Enter your guess here: ";

		std::getline(std::cin, Guess);
		
		EGuessStatus Status = BCGame.CheckGuessValidity(Guess);

		if (Status == EGuessStatus::Guess_valid)
		{
			 

			std::cout << "\n\nYou have " << rem_tries << " more tries.\n\n\n";
		}

	switch (Status)
	{
	case EGuessStatus::Guess_not_isogram:
		std::cout << "\nPlease enter an isogram. An isogram is a word without repeating ";
		std::cout << "characters:\ne.g. 'hemlock', or simply a single character.\n\n";
		break;

	case EGuessStatus::Guess_isogram_not_of_equal_length:
		std::cout << "\nPlease enter a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n ";
		break;

	case EGuessStatus::Guess_not_char_nor_equal_length_isogram:
		std::cout << "\nPlease enter a one letter character or a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n";
		break;

	case EGuessStatus::Guess_not_lowercase:
		std::cout << "\nPlease make sure your that your letter or isogram guesses are all lowercase.\n\n";
		break;

	default:
		return Guess;
	}

	std::cout << std::endl;


} while (Status != EGuessStatus::Guess_valid);
//keep looping till we get no errors

}

void play_game()
{
BCGame.Reset();

int32 word_length = BCGame.GetHiddenWordLength();
std::cout << "The word length is " << word_length << " What is your first letter or ";
std::cout << "word guess?\n\n";
// Submit valid guess to the game
// Print number of bulls and cows
std::cout << "\nYou have " << BCGame.GetMaxTries() << " total tries. Goodluck!\n\n";

// TODO change from FOR to WHILE loop once we are validating tries

int32 rem_tries;


do
{
	

	rem_tries = BCGame.GetRemainingTries();

	FText Guess = get_valid_guess(rem_tries);
	
	

		FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
		//print number of bulls and cows

		
		
		std::cout << "\nOkay, so your guess was " "'" << Guess << "'";
		std::cout << " right?\nLet's see if we have a match.";
		std::cout << "\n\n.  .  .\n\n";
		std::cout << "Bulls = " << BullCowCount.Bulls;
		std::cout << "\n\nCows = " << BullCowCount.Cows << "\n\n";
		//Call Display word in grid and display word guesses functions.
		BCGame.DispayWordGrid(BCGame.GetBullsInGridArray()); //Inner inner parameter is an FString***
	

	
	
} while (!BCGame.IsGameWon() && rem_tries > 0);

print_game_summary();

}

bool ask_to_play_again()
{

FText Response = "";
std::cout << "Would you like to play again with the same hidden word? Answer 'y' or 'n': ";
std::getline(std::cin, Response);
std::cout << std::endl;
std::cout << std::endl;
return (Response[0] == 'y') || (Response[0] == 'Y');

if(Response[0] == 'y' || Response[0] == 'Y') {
	std::cin.clear();
	FText Response2 = "";
	std::getline(std::cin, Response2);
	std::cout << "Would you like to play again with the same word? Answer 'y' or 'n': ";
	if ((Response2[0] == 'y' || Response2[0] == 'Y'))
	{
		BCGame.SetbWithSameWord(true);
	}
	else
	{
		BCGame.SetbWithSameWord(false);
	}
}

}

void print_game_summary()
{
//TODO add a game summary
if (BCGame.IsGameWon()) {
std::cout << “\n\n\nCongratulations! You’ve won the Game!\n\n\n”;
}
else {
std::cout << “\n\n\nSorry you’ve lost.\n\n\n”;
}
}

#pragma once
#include
#include
#include
#include
#define TMap std::map

using FString = std::string;
using int32 = int;

//all values initialised to zero
struct FBullCowCount
{
int32 Bulls = 0;
int32 Cows = 0;

};

enum class EGuessStatus
{
Guess_invalid,
Guess_valid,
Guess_not_isogram,
Guess_isogram_not_of_equal_length,
Guess_not_char_nor_equal_length_isogram,
Guess_not_lowercase,
Guess_not_entered
};

class FBullCowGame
{
public:

FBullCowGame(); //constructor 
char* GetBullsInGridArray();
void GetDifficulty(); 
int32 GetGuessPos(); //implemented
FString GetIsogramWord();
int32 GetMaxTries(); //implemented
int32 GetRemainingTries(); //implemented
int32 GetHiddenWordLength(); //implemented 
void SetbWithSameWord(bool WithSameWord);
bool IsBull(FString) const; // implemented
bool IsCow(FString) const; //implemented
bool IsGameWon() const; //implemented
char* CreateBullsInGridArray(char* arrayBullsGrid, int32 Pos, char letter);
FString DispayWordGrid(char[]);
EGuessStatus CheckGuessValidity(FString Guess); //implemented
FBullCowCount SubmitValidGuess(FString Word); //implemented
void Reset(); //implemented

private:
//see constructor for initialization
int32 RemTries;
FString MyHiddenWord;
bool bGameWon;
bool IsIsogram(FString) const; //implemented
bool IsLowercase(FString Word) const; //implemented
char Difficulty;
bool bWithSameWord;
char* ArrayBullsGrid; //decalre an with Hiddenwordlength
//change all char* methods to char array methods
};

#include “FBullCowGame.h”

FBullCowGame::FBullCowGame() { Reset(); } //default constructor

char* FBullCowGame::GetBullsInGridArray()

{
return ‘c’;//return arrayBullsGrid
//try save as FString
}

void FBullCowGame::GetDifficulty() //***function GetDifficulty pb
{
std::cout << “Okay player, choose a difficulty so we can begin. You can either choose ‘1’ for EASY, ‘2’ for MEDIUM, or ‘3’ for HARD. Your chosen difficulty\n”;
std::cout << “will determine the length of your word as well as the maximum number of tries that you have.\n”;
std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
int32 intdifficulty;
FString confirm;

while (confirm[0] != 'y' || 'Y') 

{


	while (!(std::cin >> intdifficulty) || (intdifficulty > 3 && intdifficulty < 1))
	{

		std::cout << "\n\nThe difficulty you provide must be an integer number. e.g. '1 (EASY)'\n\n";
		std::cout << "Also the  difficulty has to be less than or equal to '3', but not less than 1. Try again. \n\n";
		std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
		std::cin.clear();
		std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


	}

	std::cin.clear();
	std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

	if (intdifficulty == 1)
	{
		std::cout << "Okay so you chose to play in 'EASY' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{

			Difficulty = 'e'; //EASY
		}
	}
	
	else if (intdifficulty == 2)
	{
		std::cout << "Okay so you chose to play in 'MEDIUM' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{
			Difficulty = 'm'; //MEDIUM
		}
	}

	else if (intdifficulty == 3)
	{
		std::cout << "Okay so you chose to play in 'HARD' mode correct?\n";
		std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

		confirm = "";
		std::getline(std::cin, confirm);
		std::cin.clear();

		if (confirm[0] != 'y' || 'Y')
		{
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

		}

		else
		{
			Difficulty = 'h'; //HARD
		}
	}


	else
	{
		std::cout << "Invalid input.";
	}
}


//TODO implement difficulty function
//depends on the user's integer response 1:Easy, 2:Medium, 3:Hard --> maybe case?
//should be one of the first calls
//determines wordlength indirectly***
//so e.g. if 1 (easy) returns  a determined wordlength from 1 to 5. 2 (medium) 6 to 10 3 (hard) 11-17
//but maxtries is also determined by difficulty
//return difficulty-- maybe should be string constant?

}

int32 FBullCowGame::GetGuessPos() { //***function GetGuessPos pb

int32 Pos;


while (!(std::cin >> Pos) || (Pos  > (GetHiddenWordLength() - 1) && Pos < 0))
{

	std::cout << "\n\nThe isogram position you provide must be an integer number.\n\n";
	std::cout << "Also the isogram position has to be less than or equal to '" << (GetHiddenWordLength() - 1) << "', but also not less than '0'. Try again. \n\n";
	std::cin.clear();
	std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


}


std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

return Pos; 

}

FString FBullCowGame::GetIsogramWord() //difficulty wordlength
{
//TODO implement switch statement containing a library of isogram, returns a random isogram of case ‘no.’ to Reset
//for nest switch statement

//if difficulty is 1 chose from 1-6, 2 choose from 7-11, 3 choose from 12-17 etc. using rand function.
int32 randwl;
if (Difficulty == 'e')
{
	randwl = rand() % 5 + 1;
}
else if (Difficulty == 'm')
{
	randwl = rand() % 10 + 6;
}
else if (Difficulty == 'h')
{
	randwl = rand() % 17 + 11;
}



//random word length declared differently for different cases
switch (randwl)
{
case 1:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ {1, "a" }, {2, "i"}, {3, "o"}, {4, "p"}, {5, "q"} };
	//call function get randword
	return hiddenword[randint];
}
	
	break;
case 2: 
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "ax" }, { 2, "go" }, { 3, "li" }, { 4, "we" }, { 5, "ox" } };
	//to lower the user's guess
	//call function get randword
	//tell them there are no proper nouns in this game--that all word guesses can be lowercase
	return hiddenword[randint];
}
	break;
case 3:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "aft" }, { 2, "yak" }, { 3, "zit" }, { 4, "fen" }, { 5, "hun" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 4:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "soap" }, { 2, "list" }, { 3, "dork" }, { 4, "dike" }, { 5, "pint" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 5:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "bulky" }, { 2, "water" },{ 3, "scald" }, { 4, "drake" }, { 5, "light" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 6:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "planet" }, { 2, "dragon" }, { 3, "mother" }, { 4, "burned" }, { 5, "simple" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 7:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "pasture" }, { 2, "charmer" }, { 3, "longest" }, { 4 , "pokemon" }, { 5, "senator" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 8:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "acervuli" }, { 2, "acetoxyl" }, { 3, "question" }, { 4, "fracture" }, { 5, "triangle" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 9:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "reduction" }, { 2, "advection" }, { 3, "grandiose" }, { 4, "baulkiest" }, { 5, "dragonfly " } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 10:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "boyfriends" }, { 2, "dumbwaiter" }, { 3, "juxtaposed" }, { 4, "aftershock" }, { 5, "waveringly" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 11:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "misanthrope" }, { 2, "vouchsafing" }, { 3, "palindromes" }, { 4, "republicans" }, { 5, "stenography" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 12:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "adsorptively" }, { 2, "farsightedly" }, { 3, "discrepantly" }, { 4, "incomputable" }, { 5, "outspreading" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 13:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "unsympathized" }, { 2, "hydromagnetic" }, { 3, "flamethrowing" }, { 4,  "troublemaking" }, { 5, "misconjugated" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 14:
{
	int32 randint = rand() % 5 + 1;
	TMap <int32, FString> hiddenword{ { 1, "dermatoglyphic" }, { 2, "troublemakings" }, { 3, "ambidextrously" }, { 4, "pseudomythical" },{ 5, "subformatively" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 15:
{
	int32 randint = rand() % 4 + 1;
	TMap <int32, FString> hiddenword{ { 1, "dermatoglyphics" }, { 2, "hydropneumatics" }, { 3, "misconjugatedly" }, { 4, "uncopyrightable" } };
	//call function get randword
	return hiddenword[randint];
}
	break;
case 16:
{
	
	TMap <int32, FString> hiddenword{ { 1, "uncopyrightables" } };
	//call function get randword
	return hiddenword[1];
}
	break;
case 17:
{
	TMap <int32, FString> hiddenword{ { 1, "subdermatoglyphic" } };
	//call function get randword
	return hiddenword[1];
}
	break;

}

//case of switch library of word calls a const function that returns a wordlength based on difficulty.-- in this case I guess that function would be GetDifficulty. Get difficulty contains a TMap <difficult, rand wordlength>.	

}

int32 FBullCowGame::GetMaxTries() //***function GetMaxTries pb
{
//is this going to be called outside? and if so is the variable determined outside. If not use a getter
switch (Difficulty) {
case ‘e’:
{
TMap<int32, int32> WordLengthToMaxTries{ {1, 26}, {2, 22}, {3, 18}, {4, 15}, {5, 12} };// (right: wordlength, left: maxtries)–also gets wordlength and maxtries
//TODO maxtries should be a function call that is dependent on difficulty–> function:SetMaxTries–> calls GetDifficulty
//Each difficult returns different maxtries

	return WordLengthToMaxTries[MyHiddenWord.length()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
}

case 'm':
{
	TMap<int32, int32> WordLengthToMaxTries{  {6, 11}, {7, 11}, {8, 10}, {9, 10}, {10, 10} };// (right: wordlength, left: maxtries)--also gets wordlength and maxtries
																	 //TODO maxtries should be a function call that is dependent on difficulty--> function:SetMaxTries--> calls GetDifficulty
																	 //Each difficult returns different maxtries


	return WordLengthToMaxTries[MyHiddenWord.length()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
}

case 'h':
{
	TMap<int32, int32> WordLengthToMaxTries{ {11, 8}, {12, 7}, {13, 6}, {14, 5}, {15, 4}, {16, 4}, {17, 4} };// (right: wordlength, left: maxtries)--also gets wordlength and maxtries
																			//TODO maxtries should be a function call that is dependent on difficulty--> function:SetMaxTries--> calls GetDifficulty
																			//Each difficult returns different maxtries
	
	
	return WordLengthToMaxTries[GetHiddenWordLength()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
}

}

}

int32 FBullCowGame::GetRemainingTries() { return --RemTries; } //***function GetRemaining Tries pb

int32 FBullCowGame::GetHiddenWordLength() //***function GetHiddenWordLength pb
{
int32 HiddenWordLength = MyHiddenWord.length();
return HiddenWordLength;
}

void FBullCowGame::SetbWithSameWord(bool WithSameWord)
{
if (WithSameWord = true)
{
bWithSameWord = true;
}
else
{
bWithSameWord = false;
}
}

bool FBullCowGame::IsBull(FString) const { return false; } //***function IsBull pb

bool FBullCowGame::IsCow(FString) const { return false; } //***function IsCow pb
//loop asking for guesses while the game is NOT won
//and there are still tries remaining

bool FBullCowGame::IsGameWon() const { return bGameWon; } //***function IsGameWon pb

char *recvmsg()
{
int length = 5;

char* buffer = new char[length];
std::string StrPos;
for (int i; i < 5; i++)
{
	std::getline(std::cin, StrPos);

	buffer[i] = StrPos[0];

}
return buffer;

}

char* FBullCowGame::CreateBullsInGridArray(char* arrayBullsGrid , int32 Pos, char letter) //***function DisplayWordInGrid pb
{
//displays bulls in word grid
//append num. cows at the end
//should resemble hangman-esque word grid
//if bull, return/get the letter and the position…
//if cow only dsiplay the number of cows at the end of the grid-- maybe should be seperated
//should be called within sumbit_valid_guess
//returns a string so that Display Cows can use it

//store the loop contents as a string using +=

std::vector<char> arrayBullsGrid(MyHiddenWord.length()); //I don't want to declare the variable withing the function. All I want to do is change the contents of the array.
//I want arrayBullsGrid declared once and only once, outside of the function.***
//remeber to add FString WordBlanks maybe with the print Cows Function
for (int32 i = 0; i < MyHiddenWord.length(); i++)
{
	if (Pos == i ) 
	{
		
		arrayBullsGrid[i] = letter;
	
		//currently loops writes over contnts of WordGrid when gets new Pos
		//save old wordgrid
	}

}


 arrayBullsGrid = ArrayBullsGrid;//assign the result to the private member***
//try save as FString, FString is a char array***

}

FString FBullCowGame::DispayWordGrid(char* ArrayBullsGrid) //can accept an FString***
{
FBullCowCount BullCowCount;

FString WordGrid;
FString WordBlanks;

int32 size = sizeof(ArrayBullsGrid); //arrays in c++ don't have member functions
for (int32 i = 0; i < size; i++) //FString is a char array***
{
	if (ArrayBullsGrid[i] = NULL)
	{
		WordGrid += "  ";
	}

	else
	{
		WordGrid += ArrayBullsGrid[i] + " ";
	}

}


for (int32 i = 0; i < MyHiddenWord.length(); i++)
{
	WordBlanks += "_ ";
}

return WordGrid + "You have '" + std::to_string(BullCowCount.Cows) + "' Cows\n" + WordBlanks;

}

EGuessStatus FBullCowGame::CheckGuessValidity(FString Guess) //***function CheckGuessValidity pb
{
if (!IsIsogram(Guess))//if the guess isn’t an isogram, TODO write function
{

	return EGuessStatus::Guess_not_isogram;
}
else if (Guess.length() > GetHiddenWordLength())
{
	return EGuessStatus::Guess_isogram_not_of_equal_length;
}
else if (1 < Guess.length() && Guess.length() < GetHiddenWordLength())
{
	return EGuessStatus::Guess_not_char_nor_equal_length_isogram;
}
else if (Guess.length() < 1) {
	return EGuessStatus::Guess_not_entered;
}
else if (!IsLowercase(Guess))//TODO write function
{
	return EGuessStatus::Guess_not_lowercase;
}
else
{
	return EGuessStatus::Guess_valid;
}

	IsIsogram(Guess);
//return an error
//if guess is too long,
	//return and error
//if position is not specified,
	//return an error
//if guess isn't all lowercase,
	//return an error
//otherwise
	//return OK

}

FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess) //***function SubmitValidGuess pb
{
/counts bulls and cows and increments
try no.; assuming valid guess
/
//increments the turn no.

//setup return var.
FBullCowCount BullCowCount;
//loops through all letters in guess
int32 WordLength = MyHiddenWord.length(); //assuming same length as guess

if (Guess.length() == 1)
{
	FString StrPos = "";


	std::cout << "Enter a postion within the hidden isogram";

	std::cout << " at which you think your single character guess may match\n\n";

	std::cout << "e.g (0, 1, 2, 3, etc.). Keep in mind that first ";

	std::cout << "letter of the hidden isogram is at '0' and the last is at ";

	std::cout << "'" << (GetHiddenWordLength() - 1) << "' \n\n\n";

	std::cout << "Enter a position that is at least, but no more than " << (GetHiddenWordLength() - 1) << " here:  ";

	

	


	int32 Pos = GetGuessPos();
	

	if(Guess[0] == MyHiddenWord[Pos])

	{ 
		CreateBullsInGridArray(ArrayBullsGrid, Pos, Guess[0]);//Initialize length;

		BullCowCount.Bulls++;
		//pass 'Guess[0]' and pass 'Pos'

	}

	else if (Guess[0] != MyHiddenWord[Pos])
	{
		for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
		{
			if (Guess[0] == MyHiddenWord[MHWChar])
			{
				
				BullCowCount.Cows++;
				//pass BullCowCount.Cow/call BullCowCount.Cow w/in new function DisplayCowCount
			}
		}
	}
}
else
{
	//loop though all letters in the hidden word
	for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
	{
		//compare letters against hidden wor 1 at a time
		for (int32 GChar = 0; GChar < WordLength; GChar++)
		{
			//if match then
			if (Guess[GChar] == MyHiddenWord[MHWChar])
			{
				//increment bullls if they're in the same place
				if (MHWChar == GChar) {

					CreateBullsInGridArray(ArrayBullsGrid, GChar, Guess[GChar]);

					BullCowCount.Bulls++; //only if on same increment
					//return position
				}
				else {
					BullCowCount.Cows++; //must be cow if not on same increment
					//return position
				}
				//increment cows if they're not
			}
		}
	}
}
if (BullCowCount.Bulls == GetHiddenWordLength())
{
	bGameWon = true;
}

else
{
	bGameWon = false;
}
return BullCowCount;

}

void FBullCowGame::Reset() //***function Reset pb
{
GetDifficulty();

// why does RemTries work up here? Does the prgram wait for a definition of MyHiddenWord? Why isn’t RemTries -892790?
if (bWithSameWord != true)
{
MyHiddenWord = GetIsogramWord();
}
//TODO implement working TMap structure

RemTries = GetMaxTries();

}

bool FBullCowGame::IsIsogram(FString Word) const //***function IsIsogram pv
{
if (Word.length() <= 1) { return true; }
TMap <char, bool> LetterSeen;
for (auto Letter : Word) //for all letters of the word
{
Letter = tolower(Letter); //handle mixed case
if (LetterSeen[Letter])
{
return false; //we do NOT have an isogram
}
else
{
LetterSeen[Letter] = true;
}

}
//Time dependence 'n'
//sort all chars of HiddenWord alphabetically
/*Loop through all the letters of the word. If the
letter is not in the map, we do not have an isogram. Otherwise, add the letter
to the map*/
//loop through the character array of HiddenWord and search for dupilcate chars
//return true if Isogram--> false otherwise
//treat zero or one letter words as isograms
//for example in cases where /0 is entered

}

bool FBullCowGame::IsLowercase(FString Word) const //***function IsLowercase pv
{
for (auto Letter : Word)
{
if (!islower(Letter))
{// if not a lowercase letter
return false;
}

	else 
	{
		return true;
	}
}

}

Sorry that no one has been able to help you yet, your post is a bit of a brickwall :grin:

Maybe you should try and compare it to the finished version of Ben line for line yourself as the chances of someone coming around the corner and comparing their text line to line with yours is quite slim :frowning:

I hope you find your solution and sorry for not being able to bring any actual help!

I would love to try and assist you with your problem, but its very hard to read through your code since the format is a bit all over the place. Would you be able to format your entire solution and separate the code by file?

Sorry, about the formatting I could definitely trim it down. I only had issues with certain areas anyway. Thank you for responding. I didn’t think anyone looked at it yet thanks.

Surround your code with 3 back ticks

```
Code
```

So, I managed to solve some of the problems I had so far by myself. I figured out why I couldn’t debug my program (Because visual studio doesn’t run programs that don’t compile, which I forgot.) I don’t know why Print intro didn’t run the first time, but I nevertheless here is my main issue. I don’t know how to return a character array from a function. Most of my other function operate on the expectation that I can pass the array between them. What’s the easiest way to do that in C++? Because I’m confused. It’s fairly simple in Java to define a character array as an data type and pass that, C++ is different though. Also in a certain part of my code. I think I’ve made a infinite loop. I can’t get out of the while loop of the function GetDifficulty(). Can someone help me figure out if my logic is right in that method. By the way. Sorry for dumping my entire program on you guys without the formatting.

Here is GetDifficulty()

void FBullCowGame::GetDifficulty()  //***function GetDifficulty pb 
{
	std::cout << "Okay player, choose a difficulty so we can begin. You can either choose '1' for EASY, '2' for MEDIUM, or '3' for HARD. Your chosen difficulty\n";
	std::cout << "will determine the length of your word as well as the maximum number of tries that you have.\n";
	std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
	int32 intdifficulty;
	FString confirm;

	while (confirm[0] != 'y' || 'Y') 
	
	{
	

		while (!(std::cin >> intdifficulty) || (intdifficulty > 3 && intdifficulty < 1))
		{

			std::cout << "\n\nThe difficulty you provide must be an integer number. e.g. '1 (EASY)'\n\n";
			std::cout << "Also the  difficulty has to be less than or equal to '3', but not less than 1. Try again. \n\n";
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


		}

		std::cin.clear();
		std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

		if (intdifficulty == 1)
		{
			std::cout << "Okay so you chose to play in 'EASY' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{

				Difficulty = 'e'; //EASY
			}
		}
		
		else if (intdifficulty == 2)
		{
			std::cout << "Okay so you chose to play in 'MEDIUM' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{
				Difficulty = 'm'; //MEDIUM
			}
		}

		else if (intdifficulty == 3)
		{
			std::cout << "Okay so you chose to play in 'HARD' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{
				Difficulty = 'h'; //HARD
			}
		}


		else
		{
			std::cout << "Invalid input.";
		}
	}

	
	//TODO implement difficulty function
	//depends on the user's integer response 1:Easy, 2:Medium, 3:Hard --> maybe case?
	//should be one of the first calls
	//determines wordlength indirectly***
	//so e.g. if 1 (easy) returns  a determined wordlength from 1 to 5. 2 (medium) 6 to 10 3 (hard) 11-17
	//but maxtries is also determined by difficulty
    //return difficulty-- maybe should be string constant?
	

} 

And here is the entire program Formatted:

/*This is the console executable, that makes use of the BullCow class
This acts as the view in a MVC pattern, and is responsible for all
user int32eraction. For game logic see the FBullCowGame class.*/

#include <iostream>
#include <string>
#include "FBullCowGame.h"


using FText = std::string;


void print_intro();
FText get_valid_guess(int32 rem_tries);
void play_game();
bool ask_to_play_again();
void print_game_summary();

FBullCowGame BCGame;


int main()
{
	bool bplay_again = false;


	do {
		

		print_intro();

		play_game();

		bplay_again = ask_to_play_again();


		
	} 
	
	while (bplay_again);

	return 0;
}


void print_intro()
{

	
	
	//introducing the game
	
	std::cout << "Welcome to the Bulls and Cows game!" << std::endl << std::endl;
	std::cout << "In this game you will be required to guess an isogram that is of some ";
	std::cout << " characters in length; however, you will only be alloted a limited number of ";
	std::cout << "letter or word guesses, so chose wisely. Goodluck! I hope you have fun! :)\n";
	std::cout << "{   }  {   }                          \n";
	std::cout << " ---    ---                           \n";
	std::cout << "  {     }                             \n";
	std::cout << "------------   &   -------------      \n";
	std::cout << "\\ (.)  (.) /       \\  (.)  (.) /    \n";
	std::cout << " \\        /         \\         /     \n";
	std::cout << "  \\      /           \\       /      \n";
	std::cout << "   -=--=-              -=--=-         \n";
	std::cout << "  / |   | \\          / |   |  \\     \n";
	std::cout << " /  o   o  \\        /  o   o   \\    \n";
	std::cout << "|           |-     |            |-    \n";
	std::cout << "|     o     | |    |    (  )    |  |  \n";
	std::cout << " -----------  |     -----------    |  \n";
	std::cout << "    |   |     o        |   |       o  \n";
	std::cout << "    o   o              o   o          \n";
	std::cout << std::endl << std::endl;
	FString i = "is";

	//TODO modify game summary


	//getting a guess from the player
	
	

	return; 
}

//repeat the guess back to them

//loop continually until user gives valid guess
FText get_valid_guess(int32 rem_tries)
{
	EGuessStatus Status = EGuessStatus::Guess_invalid;
	
	do {
		//get guess from player
		
		FText Guess = "";

			std::cout << "Enter your guess here: ";

			std::getline(std::cin, Guess);
			
			EGuessStatus Status = BCGame.CheckGuessValidity(Guess);

			if (Status == EGuessStatus::Guess_valid)
			{
				 

				std::cout << "\n\nYou have " << rem_tries << " more tries.\n\n\n";
			}

		switch (Status)
		{
		case EGuessStatus::Guess_not_isogram:
			std::cout << "\nPlease enter an isogram. An isogram is a word without repeating ";
			std::cout << "characters:\ne.g. 'hemlock', or simply a single character.\n\n";
			break;

		case EGuessStatus::Guess_isogram_not_of_equal_length:
			std::cout << "\nPlease enter a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n ";
			break;

		case EGuessStatus::Guess_not_char_nor_equal_length_isogram:
			std::cout << "\nPlease enter a one letter character or a " << BCGame.GetHiddenWordLength() << " letter isogram word.\n\n";
			break;

		case EGuessStatus::Guess_not_lowercase:
			std::cout << "\nPlease make sure your that your letter or isogram guesses are all lowercase.\n\n";
			break;

		default:
			return Guess;
		}

		std::cout << std::endl;


	} while (Status != EGuessStatus::Guess_valid);
	//keep looping till we get no errors

	
}


void play_game() 
{
	BCGame.Reset();
	
	int32 word_length = BCGame.GetHiddenWordLength();
	std::cout << "The word length is " << word_length << " What is your first letter or ";
	std::cout << "word guess?\n\n";
	// Submit valid guess to the game
	// Print number of bulls and cows
	std::cout << "\nYou have " << BCGame.GetMaxTries() << " total tries. Goodluck!\n\n";
	
	// TODO change from FOR to WHILE loop once we are validating tries

	int32 rem_tries;
	
	
	do
	{
		

		rem_tries = BCGame.GetRemainingTries();

		FText Guess = get_valid_guess(rem_tries);
		
		

			FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
			//print number of bulls and cows

			
			
			std::cout << "\nOkay, so your guess was " "'" << Guess << "'";
			std::cout << " right?\nLet's see if we have a match.";
			std::cout << "\n\n.  .  .\n\n";
			std::cout << "Bulls = " << BullCowCount.Bulls;
			std::cout << "\n\nCows = " << BullCowCount.Cows << "\n\n";
			//Call Display word in grid and display word guesses functions.
			BCGame.DispayWordGrid(BCGame.GetBullsInGridArray()); //Inner inner parameter is an FString***
		

		
		
	} while (!BCGame.IsGameWon() && rem_tries > 0);

	print_game_summary();
}

bool ask_to_play_again()
{
	
	FText Response = "";
	std::cout << "Would you like to play again with the same hidden word? Answer 'y' or 'n': ";
	std::getline(std::cin, Response);
	std::cout << std::endl;
	std::cout << std::endl;
	return (Response[0] == 'y') || (Response[0] == 'Y');

	if(Response[0] == 'y' || Response[0] == 'Y') {
		std::cin.clear();
		FText Response2 = "";
		std::getline(std::cin, Response2);
		std::cout << "Would you like to play again with the same word? Answer 'y' or 'n': ";
		if ((Response2[0] == 'y' || Response2[0] == 'Y'))
		{
			BCGame.SetbWithSameWord(true);
		}
		else
		{
			BCGame.SetbWithSameWord(false);
		}
	}

}

void print_game_summary()
{
	//TODO add a game summary
	if (BCGame.IsGameWon()) {
		std::cout << "\n\n\nCongratulations! You've won the Game!\n\n\n";
	}
	else {
		std::cout << "\n\n\nSorry you've lost.\n\n\n";
	}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

#pragma once
#include <string>
#include <iostream>
#include <map>
#include <vector>
#define TMap std::map

using FString = std::string;
using int32 = int;

//all values initialised to zero
struct FBullCowCount 
{
	int32 Bulls = 0;
	int32 Cows = 0;
	
};

enum class EGuessStatus
{
	Guess_invalid,
	Guess_valid,
	Guess_not_isogram,
	Guess_isogram_not_of_equal_length,
	Guess_not_char_nor_equal_length_isogram,
	Guess_not_lowercase,
	Guess_not_entered
};


class FBullCowGame 
{
public:
	
	FBullCowGame(); //constructor 
	char* GetBullsInGridArray();
	void GetDifficulty(); 
	int32 GetGuessPos(); //implemented
	FString GetIsogramWord();
	int32 GetMaxTries(); //implemented
	int32 GetRemainingTries(); //implemented
	int32 GetHiddenWordLength(); //implemented 
	void SetbWithSameWord(bool WithSameWord);
	bool IsBull(FString) const; // implemented
	bool IsCow(FString) const; //implemented
	bool IsGameWon() const; //implemented
	char* CreateBullsInGridArray(char* arrayBullsGrid, int32 Pos, char letter);
	FString DispayWordGrid(char[]);
	EGuessStatus CheckGuessValidity(FString Guess); //implemented
	FBullCowCount SubmitValidGuess(FString Word); //implemented
	void Reset(); //implemented
	




private:
	//see constructor for initialization
	int32 RemTries;
	FString MyHiddenWord;
	bool bGameWon;
	bool IsIsogram(FString) const; //implemented
	bool IsLowercase(FString Word) const; //implemented
	char Difficulty;
	bool bWithSameWord;
	char* ArrayBullsGrid; //decalre an with Hiddenwordlength
	//change all char* methods to char array methods
};
//------------------------------------------------------------------------------------------------------------------------------------------------------

#include "FBullCowGame.h"



FBullCowGame::FBullCowGame() { Reset(); } //default constructor 



/**char* FBullCowGame::GetBullsInGridArray()

{
	return 'c';//return arrayBullsGrid
	//try save as FString 
}*/


void FBullCowGame::GetDifficulty()  //***function GetDifficulty pb 
{
	std::cout << "Okay player, choose a difficulty so we can begin. You can either choose '1' for EASY, '2' for MEDIUM, or '3' for HARD. Your chosen difficulty\n";
	std::cout << "will determine the length of your word as well as the maximum number of tries that you have.\n";
	std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
	int32 intdifficulty;
	FString confirm;

	while (confirm[0] != 'y' || 'Y') 
	
	{
	

		while (!(std::cin >> intdifficulty) || (intdifficulty > 3 && intdifficulty < 1))
		{

			std::cout << "\n\nThe difficulty you provide must be an integer number. e.g. '1 (EASY)'\n\n";
			std::cout << "Also the  difficulty has to be less than or equal to '3', but not less than 1. Try again. \n\n";
			std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


		}

		std::cin.clear();
		std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

		if (intdifficulty == 1)
		{
			std::cout << "Okay so you chose to play in 'EASY' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{

				Difficulty = 'e'; //EASY
			}
		}
		
		else if (intdifficulty == 2)
		{
			std::cout << "Okay so you chose to play in 'MEDIUM' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{
				Difficulty = 'm'; //MEDIUM
			}
		}

		else if (intdifficulty == 3)
		{
			std::cout << "Okay so you chose to play in 'HARD' mode correct?\n";
			std::cout << "Enter 'y' (Yes) to confirm or 'n' (No) to choose another difficulty: ";

			confirm = "";
			std::getline(std::cin, confirm);
			std::cin.clear();

			if (confirm[0] != 'y' || 'Y')
			{
				std::cout << "Enter either 1 (easy), 2 (medium), or 3 (hard) here: ";

			}

			else
			{
				Difficulty = 'h'; //HARD
			}
		}


		else
		{
			std::cout << "Invalid input.";
		}
	}

	
	//TODO implement difficulty function
	//depends on the user's integer response 1:Easy, 2:Medium, 3:Hard --> maybe case?
	//should be one of the first calls
	//determines wordlength indirectly***
	//so e.g. if 1 (easy) returns  a determined wordlength from 1 to 5. 2 (medium) 6 to 10 3 (hard) 11-17
	//but maxtries is also determined by difficulty
    //return difficulty-- maybe should be string constant?
	

} 




int32 FBullCowGame::GetGuessPos()  { //***function GetGuessPos pb
	
	int32 Pos;


	while (!(std::cin >> Pos) || (Pos  > (GetHiddenWordLength() - 1) && Pos < 0))
	{

		std::cout << "\n\nThe isogram position you provide must be an integer number.\n\n";
		std::cout << "Also the isogram position has to be less than or equal to '" << (GetHiddenWordLength() - 1) << "', but also not less than '0'. Try again. \n\n";
		std::cin.clear();
		std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


	}


	std::cin.clear();
	std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
	
	return Pos; 

}




FString FBullCowGame::GetIsogramWord() //difficulty wordlength
{
	//TODO implement switch statement containing a library of isogram, returns a random isogram of case 'no.' to Reset
 //for nest switch statement

	//if difficulty is 1 chose from 1-6, 2 choose from 7-11, 3 choose from 12-17 etc. using rand function.
	int32 randwl;
	if (Difficulty == 'e')
	{
		randwl = rand() % 5 + 1;
	}
	else if (Difficulty == 'm')
	{
		randwl = rand() % 10 + 6;
	}
	else if (Difficulty == 'h')
	{
		randwl = rand() % 17 + 11;
	}



	//random word length declared differently for different cases
	switch (randwl)
	{
	case 1:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ {1, "a" }, {2, "i"}, {3, "o"}, {4, "p"}, {5, "q"} };
		//call function get randword
		return hiddenword[randint];
	}
		
		break;
	case 2: 
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "ax" }, { 2, "go" }, { 3, "li" }, { 4, "we" }, { 5, "ox" } };
		//to lower the user's guess
		//call function get randword
		//tell them there are no proper nouns in this game--that all word guesses can be lowercase
		return hiddenword[randint];
	}
		break;
	case 3:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "aft" }, { 2, "yak" }, { 3, "zit" }, { 4, "fen" }, { 5, "hun" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 4:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "soap" }, { 2, "list" }, { 3, "dork" }, { 4, "dike" }, { 5, "pint" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 5:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "bulky" }, { 2, "water" },{ 3, "scald" }, { 4, "drake" }, { 5, "light" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 6:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "planet" }, { 2, "dragon" }, { 3, "mother" }, { 4, "burned" }, { 5, "simple" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 7:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "pasture" }, { 2, "charmer" }, { 3, "longest" }, { 4 , "pokemon" }, { 5, "senator" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 8:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "acervuli" }, { 2, "acetoxyl" }, { 3, "question" }, { 4, "fracture" }, { 5, "triangle" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 9:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "reduction" }, { 2, "advection" }, { 3, "grandiose" }, { 4, "baulkiest" }, { 5, "dragonfly " } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 10:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "boyfriends" }, { 2, "dumbwaiter" }, { 3, "juxtaposed" }, { 4, "aftershock" }, { 5, "waveringly" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 11:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "misanthrope" }, { 2, "vouchsafing" }, { 3, "palindromes" }, { 4, "republicans" }, { 5, "stenography" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 12:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "adsorptively" }, { 2, "farsightedly" }, { 3, "discrepantly" }, { 4, "incomputable" }, { 5, "outspreading" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 13:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "unsympathized" }, { 2, "hydromagnetic" }, { 3, "flamethrowing" }, { 4,  "troublemaking" }, { 5, "misconjugated" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 14:
	{
		int32 randint = rand() % 5 + 1;
		TMap <int32, FString> hiddenword{ { 1, "dermatoglyphic" }, { 2, "troublemakings" }, { 3, "ambidextrously" }, { 4, "pseudomythical" },{ 5, "subformatively" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 15:
	{
		int32 randint = rand() % 4 + 1;
		TMap <int32, FString> hiddenword{ { 1, "dermatoglyphics" }, { 2, "hydropneumatics" }, { 3, "misconjugatedly" }, { 4, "uncopyrightable" } };
		//call function get randword
		return hiddenword[randint];
	}
		break;
	case 16:
	{
		
		TMap <int32, FString> hiddenword{ { 1, "uncopyrightables" } };
		//call function get randword
		return hiddenword[1];
	}
		break;
	case 17:
	{
		TMap <int32, FString> hiddenword{ { 1, "subdermatoglyphic" } };
		//call function get randword
		return hiddenword[1];
	}
		break;

	}

	//case of switch library of word calls a const function that returns a wordlength based on difficulty.-- in this case I guess that function would be GetDifficulty. Get difficulty contains a TMap <difficult, rand wordlength>.	



	

}




int32 FBullCowGame::GetMaxTries()  //***function GetMaxTries pb
{
	//is this going to be called outside? and if so is the variable determined outside. If not use a getter
	switch (Difficulty) {
	case 'e':
	{
		TMap<int32, int32> WordLengthToMaxTries{ {1, 26}, {2, 22}, {3, 18}, {4, 15}, {5, 12} };// (right: wordlength, left: maxtries)--also gets wordlength and maxtries
		//TODO maxtries should be a function call that is dependent on difficulty--> function:SetMaxTries--> calls GetDifficulty
		//Each difficult returns different maxtries


		return WordLengthToMaxTries[MyHiddenWord.length()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
	}

	case 'm':
	{
		TMap<int32, int32> WordLengthToMaxTries{  {6, 11}, {7, 11}, {8, 10}, {9, 10}, {10, 10} };// (right: wordlength, left: maxtries)--also gets wordlength and maxtries
																		 //TODO maxtries should be a function call that is dependent on difficulty--> function:SetMaxTries--> calls GetDifficulty
																		 //Each difficult returns different maxtries


		return WordLengthToMaxTries[MyHiddenWord.length()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
	}

	case 'h':
	{
		TMap<int32, int32> WordLengthToMaxTries{ {11, 8}, {12, 7}, {13, 6}, {14, 5}, {15, 4}, {16, 4}, {17, 4} };// (right: wordlength, left: maxtries)--also gets wordlength and maxtries
																				//TODO maxtries should be a function call that is dependent on difficulty--> function:SetMaxTries--> calls GetDifficulty
																				//Each difficult returns different maxtries
		
		
		return WordLengthToMaxTries[GetHiddenWordLength()]; //retrieves the wordlength from GetIsogramWord() determined by GetDifficulty***
	}

	}
}





int32 FBullCowGame::GetRemainingTries() { return --RemTries; } //***function GetRemaining Tries pb




int32 FBullCowGame::GetHiddenWordLength()  //***function GetHiddenWordLength pb
{ 
int32 HiddenWordLength = MyHiddenWord.length();
return HiddenWordLength;  
}

void FBullCowGame::SetbWithSameWord(bool WithSameWord)
{
	if (WithSameWord = true)
	{
		bWithSameWord = true;
	}
	else
	{
		bWithSameWord = false;
	}
}







bool FBullCowGame::IsBull(FString) const { return false; } //***function IsBull pb




bool FBullCowGame::IsCow(FString) const { return false; } //***function IsCow pb
//loop asking for guesses while the game is NOT won
//and there are still tries remaining



bool FBullCowGame::IsGameWon() const { return bGameWon; } //***function IsGameWon pb



char *recvmsg()
{
	int length = 5;

	char* buffer = new char[length];
	std::string StrPos;
	for (int i; i < 5; i++)
	{
		std::getline(std::cin, StrPos);

		buffer[i] = StrPos[0];

	}
	return buffer;
}

std::vector<char> FBullCowGame::CreateBullsInGridArray(char* arrayBullsGrid , int32 Pos, char letter) //***function DisplayWordInGrid pb
{
	//displays bulls in word grid
	//append num. cows at the end
	//should resemble hangman-esque word grid
	//if bull, return/get the letter and the position...
	//if cow only dsiplay the number of cows at the end of the grid-- maybe should be seperated
	//should be called within sumbit_valid_guess
	//returns a string so that Display Cows can use it

	//store the loop contents as a string using +=

	std::vector<char> arrayBullsGrid(MyHiddenWord.length()); //I don't want to declare the variable withing the function. All I want to do is change the contents of the array.
	//I want arrayBullsGrid declared once and only once, outside of the function.***
	//remeber to add FString WordBlanks maybe with the print Cows Function
	for (int32 i = 0; i < MyHiddenWord.length(); i++)
	{
		if (Pos == i ) 
		{
			
			arrayBullsGrid[i] = letter;
		
			//currently loops writes over contnts of WordGrid when gets new Pos
			//save old wordgrid
		}

	}

	
	 arrayBullsGrid = ArrayBullsGrid;//assign the result to the private member***
	//try save as FString, FString is a char array***
	 

	 return arrayBullsGrid; 
}





FString FBullCowGame::DispayWordGrid(char* ArrayBullsGrid) //can accept an FString***
{
	FBullCowCount BullCowCount;

	FString WordGrid;
	FString WordBlanks;

	int32 size = sizeof(ArrayBullsGrid); //arrays in c++ don't have member functions
	for (int32 i = 0; i < size; i++) //FString is a char array***
	{
		if (ArrayBullsGrid[i] = NULL)
		{
			WordGrid += "  ";
		}

		else
		{
			WordGrid += ArrayBullsGrid[i] + " ";
		}

	}


	for (int32 i = 0; i < MyHiddenWord.length(); i++)
	{
		WordBlanks += "_ ";
	}

	return WordGrid + "You have '" + std::to_string(BullCowCount.Cows) + "' Cows\n" + WordBlanks;


}






EGuessStatus FBullCowGame::CheckGuessValidity(FString Guess)  //***function CheckGuessValidity pb
{
	if (!IsIsogram(Guess))//if the guess isn't an isogram, TODO write function
	{
		
		
		return EGuessStatus::Guess_not_isogram;
	}
	else if (Guess.length() > GetHiddenWordLength())
	{
		return EGuessStatus::Guess_isogram_not_of_equal_length;
	}
	else if (1 < Guess.length() && Guess.length() < GetHiddenWordLength())
	{
		return EGuessStatus::Guess_not_char_nor_equal_length_isogram;
	}
	else if (Guess.length() < 1) {
		return EGuessStatus::Guess_not_entered;
	}
	else if (!IsLowercase(Guess))//TODO write function
	{
		return EGuessStatus::Guess_not_lowercase;
	}
	else
	{
		return EGuessStatus::Guess_valid;
	}

		IsIsogram(Guess);
	//return an error
	//if guess is too long,
		//return and error
	//if position is not specified,
		//return an error
	//if guess isn't all lowercase,
		//return an error
	//otherwise
		//return OK
	
}



FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess) //***function SubmitValidGuess pb
{
	/*counts bulls and cows and increments
	try no.; assuming valid guess*/
	//increments the turn no.
	
	//setup return var.
	FBullCowCount BullCowCount;
	//loops through all letters in guess
	int32 WordLength = MyHiddenWord.length(); //assuming same length as guess

	if (Guess.length() == 1)
	{
		FString StrPos = "";


		std::cout << "Enter a postion within the hidden isogram";

		std::cout << " at which you think your single character guess may match\n\n";

		std::cout << "e.g (0, 1, 2, 3, etc.). Keep in mind that first ";

		std::cout << "letter of the hidden isogram is at '0' and the last is at ";

		std::cout << "'" << (GetHiddenWordLength() - 1) << "' \n\n\n";

		std::cout << "Enter a position that is at least, but no more than " << (GetHiddenWordLength() - 1) << " here:  ";

		

		

	
		int32 Pos = GetGuessPos();
		

		if(Guess[0] == MyHiddenWord[Pos])

		{ 
			CreateBullsInGridArray(ArrayBullsGrid, Pos, Guess[0]);//Initialize length;

			BullCowCount.Bulls++;
			//pass 'Guess[0]' and pass 'Pos'

		}

		else if (Guess[0] != MyHiddenWord[Pos])
		{
			for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
			{
				if (Guess[0] == MyHiddenWord[MHWChar])
				{
					
					BullCowCount.Cows++;
					//pass BullCowCount.Cow/call BullCowCount.Cow w/in new function DisplayCowCount
				}
			}
		}
	}
	else
	{
		//loop though all letters in the hidden word
		for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
		{
			//compare letters against hidden wor 1 at a time
			for (int32 GChar = 0; GChar < WordLength; GChar++)
			{
				//if match then
				if (Guess[GChar] == MyHiddenWord[MHWChar])
				{
					//increment bullls if they're in the same place
					if (MHWChar == GChar) {

						CreateBullsInGridArray(ArrayBullsGrid, GChar, Guess[GChar]);

						BullCowCount.Bulls++; //only if on same increment
						//return position
					}
					else {
						BullCowCount.Cows++; //must be cow if not on same increment
						//return position
					}
					//increment cows if they're not
				}
			}
		}
	}
	if (BullCowCount.Bulls == GetHiddenWordLength())
	{
		bGameWon = true;
	}

	else
	{
		bGameWon = false;
	}
	return BullCowCount;
}




void FBullCowGame::Reset() //***function Reset pb
{ 
	GetDifficulty();

// why does RemTries work up here? Does the prgram wait for a definition of MyHiddenWord? Why isn't RemTries -892790?
	if (bWithSameWord != true)
	{
		MyHiddenWord = GetIsogramWord();
	}
	//TODO implement working TMap structure


	RemTries = GetMaxTries();


}




bool FBullCowGame::IsIsogram(FString Word) const //***function IsIsogram pv
{
	if (Word.length() <= 1) { return true; }
	TMap <char, bool> LetterSeen;
	for (auto Letter : Word) //for all letters of the word
	{
		Letter = tolower(Letter); //handle mixed case
		if (LetterSeen[Letter]) 
		{
			return false; //we do NOT have an isogram
		}
		else 
		{
			LetterSeen[Letter] = true;
		}

	}
	//Time dependence 'n'
	//sort all chars of HiddenWord alphabetically
	/*Loop through all the letters of the word. If the
	letter is not in the map, we do not have an isogram. Otherwise, add the letter
	to the map*/
	//loop through the character array of HiddenWord and search for dupilcate chars
	//return true if Isogram--> false otherwise
	//treat zero or one letter words as isograms
	//for example in cases where /0 is entered
}




bool FBullCowGame::IsLowercase(FString Word) const //***function IsLowercase pv
{
	for (auto Letter : Word) 
	{
		if (!islower(Letter))
		{// if not a lowercase letter 
			return false;
		}

		else 
		{
			return true;
		}
	}
	
}

Once again sorry for the formatting issue, and for the late response.

Did you just implement a lot of code without checking if anything compiles because there’s way too much wrong with this code that it seems unlikely that you would have had it compile implement 1 feature and have it break.

You’re calling a lot of functions that aren’t implemented like EGuessStatus CheckGuessValidity(FString Guess) and FBullCowCount SubmitValidGuess(FString Word).

You have a mismatch of function signatures std::vector<char> FBullCowGame::CreateBullsInGridArray(char* arrayBullsGrid, int32 Pos, char letter) for the definition and char* FBullCowGame::CreateBullsInGridArray(char* arrayBullsGrid, int32 Pos, char letter) for the declaration. And in this function you are redefining the arrayBullsGrid parameter in this first line std::vector<char> arrayBullsGrid(MyHiddenWord.length());

In one of your for loops you don’t initialise the variable having for (int i; i < 5; i++) without ever initialising i.

There’s probably more but I feel like this would be a huge undertaking to continue looking for problems.

Yes, I don’t care if it compiles quite yet. I’m more concerned on how to return a character array from a method, and what the data type is. I’ve messed with this program quite a bit since my first issue, but don’t worry I’m aware of the issues. You don’t have to point them out.

The same way you would return any other type from a function. Or are you asking about how to use std::vector? In which case

std::vector<char> GiveAlphabet()
{
    std::vector<char> alphabet;
    for(char alpha = 'a'; alpha <= 'z'; ++alpha)
        alphabet.push_back(alpha);
    return alphabet;
}

Okay thanks. Ha that was all. Yes I didn’t know how to use std::vector. Thanks for clarifying. Oh, also what is the push_back() function for exactly?

As the name implies, it inserts the variable to the end of the array.

Okay, thank you very much

Privacy & Terms