Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include "FBullCowGame.h"
  2.  
  3. FBullCowGame::FBullCowGame()
  4. {
  5. Reset();
  6. }
  7.  
  8. int FBullCowGame::GetMaxTries() const {
  9.  
  10. return MyMaxTries;
  11. }
  12.  
  13. int FBullCowGame::GetCurrentTry() const {
  14.  
  15. return MyCurrentTry;
  16. }
  17.  
  18.  
  19.  
  20. void FBullCowGame::Reset()
  21. {
  22. constexpr int MAX_TRIES = 3;
  23. MyCurrentTry = 1;
  24. const FString HIDDEN_WORD = "ant";
  25. MyCurrentTry = 1;
  26. MyMaxTries = MAX_TRIES;
  27. return;
  28. }
  29.  
  30. bool FBullCowGame::CheckGuessValidity(FString)
  31. {
  32. return false;
  33. }
  34.  
  35. //Receives a valid guess, increments turn, and returns count
  36. FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
  37. {
  38. //increment the turn number
  39. MyCurrentTry++;
  40.  
  41. //setup a return variable
  42. FBullCowCount BullCowCount;
  43.  
  44. //loop through all letters in the guess
  45. int32 HiddenWordLength = MyHiddenWord.length();
  46. for (int32 i = 0; i < HiddenWordLength; i++) {
  47.  
  48. //compare letters against the hidden word
  49. for (int32 j = 0; j < HiddenWordLength; j++) {
  50.  
  51. //if they match then
  52. if (Guess[i] == MyHiddenWord[i]) {
  53. //if they're in the same place
  54. if (i == j) {
  55. BullCowCount.Bulls++;
  56. }
  57. else {
  58. BullCowCount.Cows++;
  59. }
  60.  
  61. }
  62. }
  63. }
  64.  
  65.  
  66. return BullCowCount;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement