aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrPatrickWarner <[email protected]>2024-04-12 16:42:26 -0700
committerrPatrickWarner <[email protected]>2024-04-12 16:42:26 -0700
commit6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0 (patch)
treeaeede3bbf36d4642b13e7d8fa3b8ef859ac29810
parentminor changes to currency (diff)
downloadhomework-1-reecepwarner-6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0.tar.xz
homework-1-reecepwarner-6ef4b7dde3a91f2923a0c5b922bc1be1f4491ca0.zip
GuessingGameProgress
-rw-r--r--CST 126/Homework 1/GuessingHelper.hpp41
-rw-r--r--CST 126/Homework 1/Helper.hpp2
-rw-r--r--CST 126/Homework 1/main.cpp8
3 files changed, 46 insertions, 5 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
diff --git a/CST 126/Homework 1/Helper.hpp b/CST 126/Homework 1/Helper.hpp
index abb1a10..9509bda 100644
--- a/CST 126/Homework 1/Helper.hpp
+++ b/CST 126/Homework 1/Helper.hpp
@@ -1,6 +1,6 @@
#ifndef HELPER_HPP
#define HELPER_HPP
-
+#include <iostream>
using std::numeric_limits;
using std::streamsize;
constexpr size_t MAX_STREAM_SIZE = numeric_limits<streamsize>::max();
diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp
index 8671b6e..7743f13 100644
--- a/CST 126/Homework 1/main.cpp
+++ b/CST 126/Homework 1/main.cpp
@@ -7,13 +7,13 @@
//clear the screen after each menu choice&& change text color??
-#include <iostream>
-#include "CurrencyHelper.hpp"
+
+#include "GuessingHelper.hpp"
int main()
{
- CurrencyConversion();
-
+ //CurrencyConversion();
+ GuessingGame();
return 0;
} \ No newline at end of file