I have a lot of syntax errors that aren’t making much sense, and after reading and re-reading my code about 3 times I figured it was time to get some help looking.
Here are the errors:
All of the errors occur in this code:
#include “FBullCowGame.h”
#include
#define TMap std::map
using int32 = int;
FBullCowGame::FBullCowGame()
{
Reset();
}
int32 FBullCowGame::GetMaxTries() const { return MyMaxTries; }
int32 FBullCowGame::GetCurrentTry() const { return MyCurrentTry; }
int32 FBullCowGame::GetHiddenWordLength() const { return MyHiddenWord.length(); }
bool FBullCowGame::IsGameWon() const { return bGameIsWon; }
void FBullCowGame::Reset()
{
constexpr int32 MAX_TRIES = 8;
const FString HIDDEN_WORD = "ant";
MyMaxTries = MAX_TRIES;
MyHiddenWord = HIDDEN_WORD;
MyCurrentTry = 1; //TODO make try count increase for each successful attempt
bGameIsWon = false;
return;
}
EGuessStatus FBullCowGame::CheckGuessValidity(FString Guess) const
{
if (!IsIsogram(Guess)) // if the guess isnt an isogram
{
return EGuessStatus::Not_Isogram; // TODO write function
}
else if (false) // if the guess isnt all lowercase
{
return EGuessStatus::Not_Lowercase; //TODO write function
}
else if (Guess.length() != GetHiddenWordLength() // if the guess length is wrong
{
return EGuessStatus::Incorrect_Length;
}
else //otherwise
{
return EGuessStatus::OK;
}
}
// recieve a VALID guess, increments turn, and returns count
FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess)
{
MyCurrentTry++;
FBullCowCount BullCowCount;
int32 WordLength = MyHiddenWord.length(); // assuming same length as guess
//loop through all letters in the hidden word
for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
{
//compare letters against the guess
for (int32 GChar = 0; GChar < WordLength; GChar++)
{
// if they match then
if (Guess[GChar] == MyHiddenWord[MHWChar])
{
if (MHWChar == GChar)
{ // if they're in the same place
BullCowCount.Bulls++; // increment bulls
}
else
{
BullCowCount.Cows++; // must be a cow
}
}
}
}
if (BullCowCount.Bulls == WordLength)
{
bGameIsWon = true;
}
else
{
bGameIsWon = false;
}
return BullCowCount;
}
bool FBullCowGame::IsIsogram(FString) const
{
return true;
}