diff --git a/SandOnABarGraph.sln b/SandOnABarGraph.sln new file mode 100644 index 0000000..8754301 --- /dev/null +++ b/SandOnABarGraph.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SandOnABarGraph", "SandOnABarGraph\SandOnABarGraph.vcxproj", "{542A1EED-855B-4140-854F-EA38B602808C}" +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 + {542A1EED-855B-4140-854F-EA38B602808C}.Debug|x64.ActiveCfg = Debug|x64 + {542A1EED-855B-4140-854F-EA38B602808C}.Debug|x64.Build.0 = Debug|x64 + {542A1EED-855B-4140-854F-EA38B602808C}.Debug|x86.ActiveCfg = Debug|Win32 + {542A1EED-855B-4140-854F-EA38B602808C}.Debug|x86.Build.0 = Debug|Win32 + {542A1EED-855B-4140-854F-EA38B602808C}.Release|x64.ActiveCfg = Release|x64 + {542A1EED-855B-4140-854F-EA38B602808C}.Release|x64.Build.0 = Release|x64 + {542A1EED-855B-4140-854F-EA38B602808C}.Release|x86.ActiveCfg = Release|Win32 + {542A1EED-855B-4140-854F-EA38B602808C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {06310D73-285B-4774-BEB3-F276742400A2} + EndGlobalSection +EndGlobal diff --git a/SandOnABarGraph/SandOnABarGraph.cpp b/SandOnABarGraph/SandOnABarGraph.cpp new file mode 100644 index 0000000..a90cd07 --- /dev/null +++ b/SandOnABarGraph/SandOnABarGraph.cpp @@ -0,0 +1,77 @@ +// SandOnABarGraph.cpp : This file contains the 'main' function. Program execution begins and ends there. +// This file is given as a starting point to help you with your coursework :). +// You will want to split this single file into multiple classes, objects and methods fairly early on. +// Author: Chris Bass +// SID: 1234567890 + +#include +#include +#include +#include +#include + +using namespace std; + +int main() +{ + cout << "Sand On A Bar Graph Problem Program Title!" << endl; + cout << "Author: Chris Bass" << endl; + cout << "SID: 1234567890" << endl << endl; + + // Read input data from .txt file. + // Assumes the data is in a particular format + + // Note that immediately after reading each field, we simply write them to the console. + // For the coursework you will want to change this, so that the values are stored + // in some form of temporary data-structure for further processing later on. + + // We should be checking for errors in the input file e.g. formatting at every point after a read. + // I.e. read line, check, read line, check... or read field, check, read field, check. + // However, I have only checked for some of the input file reading errors at each point. + + ifstream inputFileStream; + inputFileStream.open("bargraph1.txt"); // hardcoded filename, for now... + + if (inputFileStream.good()) + { + cout << "Input file is good start processing..." << endl << endl; + + int bar; + inputFileStream >> bar; + + while (!inputFileStream.fail()) // check for failbit + { + cout << bar << "; "; + inputFileStream >> bar; + } + + cout << endl; + + if (inputFileStream.eof()) { + cout << "Reached the end of file marker. File data read sucessfully." << endl; + } + else { + cout << "Error in input file." << endl; + } + } + else + { + cout << "Error opening input file, "; + cout << "check 'bargraph1.txt' exists in correct directory." << endl; + } + + inputFileStream.close(); + + return 0; +} + +// Run program: Ctrl + F5 or Debug > Start Without Debugging menu +// Debug program: F5 or Debug > Start Debugging menu + +// Tips for Getting Started: +// 1. Use the Solution Explorer window to add/manage files +// 2. Use the Team Explorer window to connect to source control +// 3. Use the Output window to see build output and other messages +// 4. Use the Error List window to view errors +// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project +// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/SandOnABarGraph/SandOnABarGraph.vcxproj b/SandOnABarGraph/SandOnABarGraph.vcxproj new file mode 100644 index 0000000..ac6edf7 --- /dev/null +++ b/SandOnABarGraph/SandOnABarGraph.vcxproj @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {542A1EED-855B-4140-854F-EA38B602808C} + Win32Proj + SandOnABarGraph + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/SandOnABarGraph/SandOnABarGraph.vcxproj.filters b/SandOnABarGraph/SandOnABarGraph.vcxproj.filters new file mode 100644 index 0000000..1aec8ad --- /dev/null +++ b/SandOnABarGraph/SandOnABarGraph.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/SandOnABarGraph/bargraph1.txt b/SandOnABarGraph/bargraph1.txt new file mode 100644 index 0000000..866e9e8 --- /dev/null +++ b/SandOnABarGraph/bargraph1.txt @@ -0,0 +1 @@ +2 6 3 5 2 8 1 4 2 2 5 11 1 4 11 7 \ No newline at end of file diff --git a/SandOnABarGraph/bargraph2.txt b/SandOnABarGraph/bargraph2.txt new file mode 100644 index 0000000..bc35790 --- /dev/null +++ b/SandOnABarGraph/bargraph2.txt @@ -0,0 +1 @@ +3 2 3 4 1 2 3 4 \ No newline at end of file diff --git a/SandOnABarGraph/bargraph3.txt b/SandOnABarGraph/bargraph3.txt new file mode 100644 index 0000000..409bebc --- /dev/null +++ b/SandOnABarGraph/bargraph3.txt @@ -0,0 +1 @@ +5 4 3 2 1 0 1 2 3 4 \ No newline at end of file diff --git a/SandOnABarGraph/bargraph4.txt b/SandOnABarGraph/bargraph4.txt new file mode 100644 index 0000000..ac3c253 --- /dev/null +++ b/SandOnABarGraph/bargraph4.txt @@ -0,0 +1 @@ +0 0 1 0 0 1 0 11 0 11 \ No newline at end of file