diff options
| author | Arthur Spears <[email protected]> | 2024-04-15 22:16:47 -0700 |
|---|---|---|
| committer | Arthur Spears <[email protected]> | 2024-04-15 22:16:49 -0700 |
| commit | a4ab91ea896528c57467798e5f7aba36f0c3227f (patch) | |
| tree | b89f01fe38bee15e2e3f966539f2ab4f4ec24bcd | |
| parent | add deadline (diff) | |
| download | homework-1-arthurtspears-a4ab91ea896528c57467798e5f7aba36f0c3227f.tar.xz homework-1-arthurtspears-a4ab91ea896528c57467798e5f7aba36f0c3227f.zip | |
all work up until inclass practice
| -rw-r--r-- | CST 126/Homework 1/GuessingGame.hpp | 22 | ||||
| -rw-r--r-- | CST 126/Homework 1/Homework 1.vcxproj | 8 | ||||
| -rw-r--r-- | CST 126/Homework 1/Homework 1.vcxproj.filters | 11 | ||||
| -rw-r--r-- | CST 126/Homework 1/helpers.hpp | 45 | ||||
| -rw-r--r-- | CST 126/Homework 1/main.cpp | 66 | ||||
| -rw-r--r-- | CST 126/Homework 1/menu.hpp | 52 |
6 files changed, 202 insertions, 2 deletions
diff --git a/CST 126/Homework 1/GuessingGame.hpp b/CST 126/Homework 1/GuessingGame.hpp new file mode 100644 index 0000000..fa0f85d --- /dev/null +++ b/CST 126/Homework 1/GuessingGame.hpp @@ -0,0 +1,22 @@ +#ifndef GUESSING_GAME_HPP +#define GUESSING_GAME_HPP + +#include "helpers.hpp" +#include <iostream> + +using std::cout; +using std::endl; + +inline void OutputRandomNumber() { + cout << Random(1, 10000) << endl; +} + + + + + +#endif // !GUESSING_GAME_HPP + + + + diff --git a/CST 126/Homework 1/Homework 1.vcxproj b/CST 126/Homework 1/Homework 1.vcxproj index 0a4f788..553addf 100644 --- a/CST 126/Homework 1/Homework 1.vcxproj +++ b/CST 126/Homework 1/Homework 1.vcxproj @@ -70,6 +70,9 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <IncludePath>.\;$(IncludePath)</IncludePath> + </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -129,6 +132,11 @@ <ItemGroup> <ClCompile Include="main.cpp" /> </ItemGroup> + <ItemGroup> + <ClInclude Include="GuessingGame.hpp" /> + <ClInclude Include="helpers.hpp" /> + <ClInclude Include="menu.hpp" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/CST 126/Homework 1/Homework 1.vcxproj.filters b/CST 126/Homework 1/Homework 1.vcxproj.filters index ce0c35c..a2e2650 100644 --- a/CST 126/Homework 1/Homework 1.vcxproj.filters +++ b/CST 126/Homework 1/Homework 1.vcxproj.filters @@ -19,4 +19,15 @@ <Filter>Source Files</Filter> </ClCompile> </ItemGroup> + <ItemGroup> + <ClInclude Include="helpers.hpp"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="menu.hpp"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="GuessingGame.hpp"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/CST 126/Homework 1/helpers.hpp b/CST 126/Homework 1/helpers.hpp new file mode 100644 index 0000000..f34a66d --- /dev/null +++ b/CST 126/Homework 1/helpers.hpp @@ -0,0 +1,45 @@ +#ifndef HELPERS_HPP +#define HELPERS_HPP + +#include <random> + +typedef unsigned long long uLong; +typedef unsigned char BYTE; + +inline int Random(const int& lowest, const int& highest) +{ + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<int> dis(lowest, highest); + const int random_number = dis(gen); + return random_number; +} + +inline void GenerateRandomNumbers(int arrayToFill[], const int& size) +{ + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<int> dis(0, size); + for (auto i = 0; i < size; ++i) + { + const int random_number = dis(gen); + arrayToFill[i] = random_number; + } +} +inline int add(int num, char myChar) +{ + return num + myChar; +} + +inline int add(int num, int num2, int num3) +{ + return num + num2 + num3; +} +inline int add(int num, int num2, int num3, int num4) +{ + return num + num2 + num3 + num4; +} + + + +#endif diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp index 398e580..b4c91fc 100644 --- a/CST 126/Homework 1/main.cpp +++ b/CST 126/Homework 1/main.cpp @@ -1,8 +1,70 @@ // Name: Arthur Spears // Class: CST 126 // Date: 3/31/24 -// Assignment: Homework +// Assignment: Homework 1 + +#include <iostream> +#include "helpers.hpp" +#include "menu.hpp" +#include <bitset> + +using std::cout; +using std::endl; + +struct DailyTemperature +{ + int highTemp{}; + int lowTemp{}; +}; + +enum DayOfTheWeek +{ + Sunday = 0, + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday = 6 +}; + +enum Month +{ + January = 1, + February, + March, + April, + May, + June, + July, + August, + September, + October, + November, + December +}; + +struct Date +{ + Month month; + uint8_t day; + uint16_t year; +}; + +union FloatIntUnion +{ + float intFloat; + uint32_t uInt; +}; int main() { + FloatIntUnion floatIntUnion {}; + floatIntUnion.intFloat = 1.2345f; + + std::cout << "Float: " << floatIntUnion.intFloat << std::endl; + std::cout << "Binary representation: " << std::bitset<32>(static_cast<uint32_t>(floatIntUnion.intFloat)) << std::endl; + std::cout << "As Int: " << floatIntUnion.uInt << std::endl; + std::cout << "Binary representation: " << std::bitset<32>(floatIntUnion.uInt) << std::endl; + return 0; -}
\ No newline at end of file +} diff --git a/CST 126/Homework 1/menu.hpp b/CST 126/Homework 1/menu.hpp new file mode 100644 index 0000000..8b99931 --- /dev/null +++ b/CST 126/Homework 1/menu.hpp @@ -0,0 +1,52 @@ +#ifndef MENU_H +#define MENU_H + +#include <iostream> +#include "GuessingGame.hpp" + +using std::cout; +using std::cin; +using std::endl; + +inline void DisplayMenu() { + cout << "***************************************************************" << endl; + cout << "Welcome to the menu!\n"; + cout << "1. Currency Converter\n"; + cout << "2. Guessing Game\n"; + cout << "3. Temperature Logger\n"; + cout << "5. Exit\n"; + cout << endl; + cout << "Please pick a number for your choice: "; +} + +inline void Worker() { + + int input = 0; + + DisplayMenu(); + + cin >> input; + + while (input != 5) + { + switch (input) { + case 1: + //Call Currency Function + break; + case 2: + //Call Guessing Game Function + OutputRandomNumber(); + break; + case 3: + //Call Temperature Logger + break; + default: + cout << "\nInvalid option, please pick again..\n"; + } + + DisplayMenu(); + + cin >> input; + } +} +#endif
\ No newline at end of file |