Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FBullCowGame.h"
- FBullCowGame::FBullCowGame()
- {
- Reset();
- }
- int FBullCowGame::GetMaxTries() const {
- return MyMaxTries;
- }
- int FBullCowGame::GetCurrentTry() const {
- return MyCurrentTry;
- }
- void FBullCowGame::Reset()
- {
- constexpr int MAX_TRIES = 3;
- MyCurrentTry = 1;
- const FString HIDDEN_WORD = "ant";
- MyCurrentTry = 1;
- MyMaxTries = MAX_TRIES;
- return;
- }
- bool FBullCowGame::CheckGuessValidity(FString)
- {
- return false;
- }
- //Receives a valid guess, increments turn, and returns count
- FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
- {
- //increment the turn number
- MyCurrentTry++;
- //setup a return variable
- FBullCowCount BullCowCount;
- //loop through all letters in the guess
- int32 HiddenWordLength = MyHiddenWord.length();
- for (int32 i = 0; i < HiddenWordLength; i++) {
- //compare letters against the hidden word
- for (int32 j = 0; j < HiddenWordLength; j++) {
- //if they match then
- if (Guess[i] == MyHiddenWord[i]) {
- //if they're in the same place
- if (i == j) {
- BullCowCount.Bulls++;
- }
- else {
- BullCowCount.Cows++;
- }
- }
- }
- }
- return BullCowCount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement