aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChanin Timbal <[email protected]>2024-04-27 14:05:17 -0700
committerChanin Timbal <[email protected]>2024-04-27 14:05:17 -0700
commitf94af69b62058b241e569b973a136afb4d331d46 (patch)
tree6333c9062e329593e5d7cae8a1c94bc46391a426
parentCompleted Program of Currency Conversion (diff)
downloadhomework-1-chaninnohea-f94af69b62058b241e569b973a136afb4d331d46.tar.xz
homework-1-chaninnohea-f94af69b62058b241e569b973a136afb4d331d46.zip
Homework 2 first commit
-rw-r--r--CST 126/Homework 1/main.cpp49
-rw-r--r--CST 126/Homework 2/Homework2/Base64Converter.hpp10
-rw-r--r--CST 126/Homework 2/Homework2/FindingPi.exebin0 -> 3496762 bytes
-rw-r--r--CST 126/Homework 2/Homework2/Homework2.sln31
-rw-r--r--CST 126/Homework 2/Homework2/Homework2.vcxproj145
-rw-r--r--CST 126/Homework 2/Homework2/Homework2.vcxproj.filters40
-rw-r--r--CST 126/Homework 2/Homework2/destination_file.txt0
-rw-r--r--CST 126/Homework 2/Homework2/helpers.hpp88
-rw-r--r--CST 126/Homework 2/Homework2/program.cpp70
9 files changed, 430 insertions, 3 deletions
diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp
index 8d10dad..a82ca3b 100644
--- a/CST 126/Homework 1/main.cpp
+++ b/CST 126/Homework 1/main.cpp
@@ -11,6 +11,7 @@ using std::cout;
using std::cin;
//Protoypes
+void display_options();
float convert(float input, float output, float amount);
void run_conversion(char again);
void currency_menu();
@@ -18,15 +19,57 @@ void currency_menu();
//Main to run the program
int main()
{
- char again = 'Y';
+ int option = 0;
- cout << "Welcome to my currency conversion tool!\n";
+ cout << "Welcome! Please choose an option: \n";
+ display_options();
+ cin >> option;
+ cin.ignore(100, '\n');
- run_conversion(again);
+ while (option != 0)
+ {
+ if (option == 1)
+ {
+ char again = 'Y';
+ run_conversion(again);
+ cin >> again;
+ cin.ignore(100,'\n');
+ }
+
+ else if (option == 2)
+ {
+
+ }
+
+ else if (option == 3)
+ {
+
+ }
+ else
+ {
+ cout << "That is not one of the options!";
+ display_options();
+ cin >> option;
+ cin.ignore(100, '\n');
+ }
+
+ display_options();
+ cin >> option;
+ cin.ignore(100, '\n');
+ }
return 0;
}
+//menu options
+void display_options()
+{
+ cout << "1. Currency Converter\n";
+ cout << "2. Guessing Game\n";
+ cout << "3. Temperature Logger\n";
+ cout << "0. Quit\n";
+}
+
//Conversion Calculator
float convert(float input, float output, float amount)
{
diff --git a/CST 126/Homework 2/Homework2/Base64Converter.hpp b/CST 126/Homework 2/Homework2/Base64Converter.hpp
new file mode 100644
index 0000000..704079b
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/Base64Converter.hpp
@@ -0,0 +1,10 @@
+#ifndef BASE64_CONVERTER_HPP
+#define BASE64_CONVERTER_HPP
+
+
+
+
+//encode
+//decode
+
+#endif \ No newline at end of file
diff --git a/CST 126/Homework 2/Homework2/FindingPi.exe b/CST 126/Homework 2/Homework2/FindingPi.exe
new file mode 100644
index 0000000..4b128d3
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/FindingPi.exe
Binary files differ
diff --git a/CST 126/Homework 2/Homework2/Homework2.sln b/CST 126/Homework 2/Homework2/Homework2.sln
new file mode 100644
index 0000000..487680b
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/Homework2.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34723.18
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Homework2", "Homework2.vcxproj", "{D98B5865-9F6A-4BB6-8443-3C88F9825603}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Debug|x64.ActiveCfg = Debug|x64
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Debug|x64.Build.0 = Debug|x64
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Debug|x86.ActiveCfg = Debug|Win32
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Debug|x86.Build.0 = Debug|Win32
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Release|x64.ActiveCfg = Release|x64
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Release|x64.Build.0 = Release|x64
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Release|x86.ActiveCfg = Release|Win32
+ {D98B5865-9F6A-4BB6-8443-3C88F9825603}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1A5DF82F-23DD-44E7-A5EB-9BCB8146727A}
+ EndGlobalSection
+EndGlobal
diff --git a/CST 126/Homework 2/Homework2/Homework2.vcxproj b/CST 126/Homework 2/Homework2/Homework2.vcxproj
new file mode 100644
index 0000000..6ecd492
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/Homework2.vcxproj
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>17.0</VCProjectVersion>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{d98b5865-9f6a-4bb6-8443-3c88f9825603}</ProjectGuid>
+ <RootNamespace>Homework2</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="program.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\..\..\FindingPi.exe" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="destination_file.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Base64Converter.hpp" />
+ <ClInclude Include="helpers.hpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/CST 126/Homework 2/Homework2/Homework2.vcxproj.filters b/CST 126/Homework 2/Homework2/Homework2.vcxproj.filters
new file mode 100644
index 0000000..f608380
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/Homework2.vcxproj.filters
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="program.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\..\..\FindingPi.exe">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="destination_file.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="helpers.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Base64Converter.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/CST 126/Homework 2/Homework2/destination_file.txt b/CST 126/Homework 2/Homework2/destination_file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/destination_file.txt
diff --git a/CST 126/Homework 2/Homework2/helpers.hpp b/CST 126/Homework 2/Homework2/helpers.hpp
new file mode 100644
index 0000000..0aa6251
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/helpers.hpp
@@ -0,0 +1,88 @@
+#ifndef HELPERS_HPP
+#define HELPERS_HPP
+
+
+//file reading things
+inline char* ReadTextFromFile(const char* fileName, char* buffer)
+{
+ return buffer;
+}
+
+inline char* ReadFileAsBinary(const char* fileName, char* buffer)
+{
+ try
+ {
+ //open the fstream in input mode, with binary mode
+ std::fstream file(fileName, std::ios::in | std::ios::binary);
+
+ if (!file.is.open())
+ {
+ std::cerr << "Could not open file for binary input: " << fileName;
+ return buffer;
+ }
+
+ file.seekg(0, std::ios::end);
+
+ std::streamsize size = file.tellg();
+
+ file.seekg(0, std::ios::beg);
+
+ delete[] buffer;
+
+ buffer = nullptr;
+
+ //size the buffer with a new
+ buffer = new char[size];
+
+ file.read(buffer, size);
+
+ file.close();
+
+ return buffer;
+ }
+ catch (const std::exception& ex)
+ {
+ std::cerr << "Exception during binary file input: " << fileName << "was not successfully streamed to binary";
+ ex.what()
+ return buffer;
+ }
+}
+
+//file writing things
+inline bool WriteTextToFile(const char* fileName, const char* fileContents)
+{
+ std::ostream file(fileName);
+
+ if (!file.is_open())
+ {
+ std::cerr << "Could not open file: " << fileName;
+ return false;
+ }
+
+ file << fileContents;
+
+ file.close();
+
+ return false;
+}
+
+inline bool WriteFileFromBinary(const char* fileName, const char* buffer)
+{
+ return false;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif \ No newline at end of file
diff --git a/CST 126/Homework 2/Homework2/program.cpp b/CST 126/Homework 2/Homework2/program.cpp
new file mode 100644
index 0000000..158a2be
--- /dev/null
+++ b/CST 126/Homework 2/Homework2/program.cpp
@@ -0,0 +1,70 @@
+//Chanin Timbal
+//Homework 2
+//27 April 2024
+
+#include <iostream>
+
+#include "helpers.hpp"
+#include "Base64Converter.hpp"
+
+constexpr short ARG_COUNT = 4;
+
+bool Worker();
+bool Worker(char** argv);
+
+
+
+int main(const int argc, char* argv[])
+{
+ if (argc == ARG_COUNT)
+ {
+ //run the command line version
+ Worker(argv);
+ }
+ return Worker();
+}
+
+bool Worker()
+{
+}
+
+bool Worker(char** argv)
+{
+ const char* arg1 = argv[1]; //-e -d
+ const char* arg2 = argv[2]; //source file name
+ const char* arg3 = argv[3]; //destination file name
+
+ const char option = arg1[1]; //e or d
+
+ switch (option)
+ {
+ case 'e':
+ //file reading binary
+ char* buffer = new char[1];
+
+ buffer = ReadFileAsBinary(arg2, buffer);
+ //endcoding work
+
+ bool success = WriteTextToFile(arg3, buffer);
+
+ delete[] buffer;
+
+ return success;
+ case 'd':
+ //file reading text
+ //decoding work
+ //file writing binary
+ return true;
+ default:
+ std::cerr << "Invalid command option\n" <<
+ "Valid commands:\n" <<
+ "\t-e source_file.exe destination_file.exe" <<
+ "\t\tEncodes file in source into text in destination txt file." <<
+ "\t-d source_file.txt destination file.exe" <<
+ "\t\tDecodes text in source file into the destination file.\n\n";
+ return false;
+ }
+
+
+ return false;
+} \ No newline at end of file