Skip to content

Commit

Permalink
BC35 Range-based for Loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Tristem committed Jan 18, 2016
1 parent 74ced4c commit d6d961a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions BullCowGame/FBullCowGame.cpp
Expand Up @@ -82,12 +82,18 @@ FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess)
bool FBullCowGame::IsIsogram(FString Word) const
{
// treat 0 and 1 letter words as isograms
if (Word.length() <= 1) { return true; }

// loop through all the letters of the word
// if the letter is in the map
// we do NOT have an isogram
// otherwise
// add the letter to the map as seen
TMap<char, bool> LetterSeen; // setup our map
for (auto Letter : Word) // for all letters of the word
{
Letter = tolower(Letter); // handle mixed case
if (LetterSeen[Letter]) {// if the letter is in the map
return false; // we do NOT have an isogram
} else {
LetterSeen[Letter] = true;// add the letter to the map
}
}

return true; // for example in cases where /0 is entered
}
1 change: 1 addition & 0 deletions BullCowGame/FBullCowGame.h
Expand Up @@ -36,6 +36,7 @@ class FBullCowGame
void Reset(); // TODO make a more rich return value.
FBullCowCount SubmitValidGuess(FString);


// ^^ Please try and ignore this and focus on the interface above ^^
private:
// see constructor for initialisation
Expand Down
Binary file modified Section_02.VC.db
Binary file not shown.

0 comments on commit d6d961a

Please sign in to comment.