My codes of check if the game is won

:smile: I’m new to programming and I tried to make my own codes and thought it might be fun posting it here.
So in the main.cpp I created a loop that keeps the game going until the max tries are reached or the game is won. After that check the game is won, if yes then tell the player that he has won.

	do
	{
		Getvalidguess(); 
	} 
	while (!BCinstance.Isgamewon(Guess) && BCinstance.Getcurrenttry() <= Maxtries);
	if (BCinstance.Isgamewon(Guess))
	{
		std::cout << std::endl << "You win" << std::endl;
	}
	else
	{}

in the headerfile BCgame.h public there’s

	bool Isgamewon(Fstring)const; 

then in BCgame.cpp

I coded it like this

bool FBCgame::Isgamewon(Fstring Guess)const
{
	if (Guess == Myhiddenword)
	{return true;}
	else
	{return false;}
}
1 Like

Privacy & Terms