diff options
| author | rPatrickWarner <[email protected]> | 2024-04-12 16:42:26 -0700 |
|---|---|---|
| committer | rPatrickWarner <[email protected]> | 2024-04-12 16:42:26 -0700 |
| commit | 6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0 (patch) | |
| tree | aeede3bbf36d4642b13e7d8fa3b8ef859ac29810 /CST 126/Homework 1/GuessingHelper.hpp | |
| parent | minor changes to currency (diff) | |
| download | homework-1-reecepwarner-6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0.tar.xz homework-1-reecepwarner-6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0.zip | |
GuessingGameProgress
Diffstat (limited to 'CST 126/Homework 1/GuessingHelper.hpp')
| -rw-r--r-- | CST 126/Homework 1/GuessingHelper.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/CST 126/Homework 1/GuessingHelper.hpp b/CST 126/Homework 1/GuessingHelper.hpp index 408f409..2383a1c 100644 --- a/CST 126/Homework 1/GuessingHelper.hpp +++ b/CST 126/Homework 1/GuessingHelper.hpp @@ -1,7 +1,48 @@ #ifndef GUESSING_HELPER_HPP #define GUESSING_HELPER_HPP #include "CurrencyHelper.hpp" +#include <random> int RandomNumberGenerator(const int& LowerBound, const int& UpperBound); +void GuessingGame(); + +int RandomNumberGenerator(const int& LowerBound, const int& UpperBound) +{ + std::random_device dev; + std::mt19937 rng(dev()); + std::uniform_int_distribution<std::mt19937::result_type> dist(LowerBound, UpperBound); + + return dist(rng); +} + +void GuessingGame() +{ + int GoldenSnitch = 0; + int UserGuess = 0; + size_t NumberOfGuesses = 0; + GoldenSnitch = RandomNumberGenerator(1, 10000); + do + { + + UserGuess = InputSelectionInt("Guess a number between 1 and 10,000 :"); + system("cls"); + if (UserGuess == GoldenSnitch) + { + std::cout << "Hooray! YOU WON!!!" << std::endl; + return; + } + if (UserGuess < GoldenSnitch) + { + std::cout << "Your number is less than the winning value, try a number with a larger magnitude!" << std::endl; + } + if (UserGuess > GoldenSnitch) + { + std::cout << "Your number is greater than the winning value, try a number with a smaller magnitude!" << std::endl; + } + NumberOfGuesses++; + + } while (NumberOfGuesses != 20); + +} #endif
\ No newline at end of file |