First push
This commit is contained in:
parent
6ffacf3c9b
commit
2b53962f89
32 changed files with 933 additions and 0 deletions
31
Project3.sln
Normal file
31
Project3.sln
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.33423.256
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project3", "Project3\Project3.vcxproj", "{AFA661B1-EC92-446B-8827-0E94C067E063}"
|
||||
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
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Debug|x64.Build.0 = Debug|x64
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Debug|x86.Build.0 = Debug|Win32
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Release|x64.ActiveCfg = Release|x64
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Release|x64.Build.0 = Release|x64
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Release|x86.ActiveCfg = Release|Win32
|
||||
{AFA661B1-EC92-446B-8827-0E94C067E063}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A3FB8617-7899-49C4-9530-7FFCA33D6AC0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
229
Project3/Items.cpp
Normal file
229
Project3/Items.cpp
Normal file
|
@ -0,0 +1,229 @@
|
|||
/* Cody Cook
|
||||
2023/04/13
|
||||
CS-210 Project 3
|
||||
*/
|
||||
#include "Items.h"
|
||||
|
||||
// constructors
|
||||
|
||||
// default constructor; parses default file name
|
||||
Items::Items()
|
||||
{
|
||||
if (!ParseInputFile())
|
||||
{
|
||||
// try getting a new file
|
||||
RequestNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
// constructor with a custom input option
|
||||
Items::Items(string p_inputFile = defaultItemFileName)
|
||||
{
|
||||
SetInputFile(p_inputFile);
|
||||
if (!ParseInputFile())
|
||||
{
|
||||
// try geting a new file
|
||||
RequestNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
// destructors
|
||||
|
||||
// run a set of functions when the class closes
|
||||
Items::~Items()
|
||||
{
|
||||
if (r_input.is_open())
|
||||
{
|
||||
r_input.close();
|
||||
}
|
||||
}
|
||||
|
||||
// getters
|
||||
|
||||
// prints and returns the inventory for a named item
|
||||
int Items::GetInventory(string p_item)
|
||||
{
|
||||
// search the string in the map
|
||||
auto it = r_mapping.find(p_item);
|
||||
|
||||
// if there were results
|
||||
if (it != r_mapping.end())
|
||||
{
|
||||
string times; // allow for more natural responses with the word "time"
|
||||
|
||||
// if there is only one item, it is only there "one time"
|
||||
if (it->second == 1)
|
||||
{
|
||||
times = " time.";
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it is 0 or 2 or more, then it is "times"
|
||||
times = " times.";
|
||||
}
|
||||
|
||||
// output the quantity purchased
|
||||
cout << c_red << it->first << c_normal
|
||||
<< " were purchased ";
|
||||
cout << c_red << it->second << c_normal;
|
||||
cout << times << endl;
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
// because there wasn't quantity, explain it wasn't purchased.
|
||||
cerr << c_red << p_item << c_normal
|
||||
<< " were not purchased." << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// return the string for the inputFile
|
||||
string Items::GetInputFile()
|
||||
{
|
||||
return r_inputFile;
|
||||
}
|
||||
|
||||
char Items::GetStar()
|
||||
{
|
||||
return r_star;
|
||||
}
|
||||
|
||||
// setters
|
||||
|
||||
// update the filename of the input file
|
||||
void Items::SetInputFile(string p_inputFile)
|
||||
{
|
||||
r_inputFile = p_inputFile;
|
||||
}
|
||||
|
||||
// change the star used in the histogram
|
||||
void Items::SetStar(char p_star)
|
||||
{
|
||||
r_star = p_star;
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
// ParseInputFile reads the input file and stores the data in a map; it also runs a backup of the data
|
||||
bool Items::ParseInputFile()
|
||||
{
|
||||
// try opening the file
|
||||
r_input.open(r_inputFile);
|
||||
|
||||
// if the file could not be opened
|
||||
if (!r_input.is_open())
|
||||
{
|
||||
// error out
|
||||
cout << "Error opening file "
|
||||
<< c_red << r_inputFile << c_normal << endl;
|
||||
return false;
|
||||
}
|
||||
clog << endl
|
||||
<< "Parsing "
|
||||
<< c_red << r_inputFile << c_normal
|
||||
<< "... ";
|
||||
|
||||
string line;
|
||||
// while we go through each line of the file
|
||||
while (getline(r_input, line))
|
||||
{
|
||||
// Increment the frequency of the current line into the map
|
||||
r_mapping[line]++;
|
||||
}
|
||||
// close the file
|
||||
r_input.close();
|
||||
|
||||
// run a backup of this data and return true
|
||||
SaveInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
// output the inventory based on the config
|
||||
void Items::PrintInventory(int p_type)
|
||||
{
|
||||
// find the length of the longest item to help align the output
|
||||
size_t longest = 0;
|
||||
for (const auto &entry : r_mapping)
|
||||
{
|
||||
if (entry.first.length() > longest)
|
||||
{
|
||||
longest = entry.first.length();
|
||||
}
|
||||
}
|
||||
|
||||
// output the inventory
|
||||
for (const auto &entry : r_mapping)
|
||||
{
|
||||
// output the item name with the longest item name as the width
|
||||
cout << setw(longest) << entry.first << " ";
|
||||
|
||||
// see the quantity as a number
|
||||
if (p_type == 1)
|
||||
{
|
||||
cout << c_red << entry.second << c_normal << endl;
|
||||
}
|
||||
// see the quantity as a histogram
|
||||
else if (p_type == 2)
|
||||
{
|
||||
cout << c_red << string(entry.second, r_star) << c_normal << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SaveInventory creates a backup of the data in the map
|
||||
bool Items::SaveInventory()
|
||||
{
|
||||
// open file for backup
|
||||
ofstream file(r_database);
|
||||
|
||||
// if the file isn't open
|
||||
if (!file.is_open())
|
||||
{
|
||||
// then there was a opening the file; so warn the user and exit the function
|
||||
cerr << "Error opening " << c_red << r_database << c_normal << " for backup. Please check your permissions.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// iterate through the mappings and save them to the file
|
||||
for (const auto &entry : r_mapping)
|
||||
{
|
||||
file << entry.first << " " << entry.second << endl;
|
||||
}
|
||||
|
||||
// save and close the file
|
||||
file.close();
|
||||
|
||||
// output a successful save and return true
|
||||
cout << "Backup file "
|
||||
<< c_red << r_database << c_normal
|
||||
<< " updated." << endl;
|
||||
cout << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Items::RequestNewFile()
|
||||
{
|
||||
string newFile;
|
||||
bool moveOn = false;
|
||||
while (!moveOn)
|
||||
{
|
||||
cout << endl;
|
||||
cout << "Type " << c_red << "exit" << c_normal << " to quit, or enter the filename to import: ";
|
||||
cout << c_red;
|
||||
cin >> newFile;
|
||||
cout << c_normal;
|
||||
|
||||
if (newFile == "exit")
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
SetInputFile(newFile);
|
||||
|
||||
if (ParseInputFile())
|
||||
{
|
||||
moveOn = true;
|
||||
}
|
||||
}
|
||||
}
|
52
Project3/Items.h
Normal file
52
Project3/Items.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Cody Cook
|
||||
2023/04/13
|
||||
CS-210 Project 3
|
||||
*/
|
||||
#include <iostream> // use cout and cin
|
||||
#include <string> // use strings
|
||||
#include <map> // use maps
|
||||
#include <fstream> // use files
|
||||
#include <iomanip> // use setw
|
||||
|
||||
using namespace std; // use the standard namespace
|
||||
|
||||
#pragma once // only include this file onces
|
||||
|
||||
// set some constants
|
||||
constexpr auto defaultItemFileName = "inputfile.txt"; // the default filename to import
|
||||
constexpr auto defaultDatabaseFilename = "frequency.dat"; // the default filename to export
|
||||
constexpr auto c_red = "\033[31m"; // set the terminal red color
|
||||
constexpr auto c_normal = "\033[0m"; // set the terminal normal color
|
||||
|
||||
class Items
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
Items(); // default constructor
|
||||
Items(string p_inputFile); // constructor with a custom import file
|
||||
|
||||
//destructor
|
||||
~Items(); // destructor
|
||||
|
||||
// getters
|
||||
string GetInputFile(); // return the string for the inputFile
|
||||
int GetInventory(string p_item); // return the quantity of a specific item
|
||||
char GetStar(); // get the configured star
|
||||
|
||||
//setters
|
||||
void SetInputFile(string p_inputFile); // update the filename of the input file
|
||||
void SetStar(char p_star); // set the star char
|
||||
|
||||
//methods
|
||||
void RequestNewFile(); // ask user to set new filename
|
||||
bool ParseInputFile(); // parse the configured input file
|
||||
void PrintInventory(int p_type); // output the inventory in the map
|
||||
bool SaveInventory(); // save the inventory to a file
|
||||
|
||||
private:
|
||||
string r_inputFile = defaultItemFileName; // the default file to import
|
||||
ifstream r_input; // the input file
|
||||
map<string, int> r_mapping; // the map of items and their quantities
|
||||
string r_database = defaultDatabaseFilename; // the default filename to export
|
||||
char r_star = '*'; // default star for the histogram
|
||||
};
|
BIN
Project3/Project3.aps
Normal file
BIN
Project3/Project3.aps
Normal file
Binary file not shown.
100
Project3/Project3.rc
Normal file
100
Project3/Project3.rc
Normal file
|
@ -0,0 +1,100 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Cody Cook"
|
||||
VALUE "FileDescription", "Reads inputfile.txt and outputs data about the file. Backs up to frequency.dat"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "Project3.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2023 Cody Cook"
|
||||
VALUE "OriginalFilename", "Project3.exe"
|
||||
VALUE "ProductName", "Corner Grocer: Purchase Visualizer"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
155
Project3/Project3.vcxproj
Normal file
155
Project3/Project3.vcxproj
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?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>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{afa661b1-ec92-446b-8827-0e94c067e063}</ProjectGuid>
|
||||
<RootNamespace>Project3</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>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</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" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<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="Items.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Items.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Project3.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
38
Project3/Project3.vcxproj.filters
Normal file
38
Project3/Project3.vcxproj.filters
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?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="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Items.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Items.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Project3.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
4
Project3/Project3.vcxproj.user
Normal file
4
Project3/Project3.vcxproj.user
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
BIN
Project3/Release/Items.obj
Normal file
BIN
Project3/Release/Items.obj
Normal file
Binary file not shown.
11
Project3/Release/Project3.exe.recipe
Normal file
11
Project3/Release/Project3.exe.recipe
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\cody\OneDrive - SNHU\CS-210\Project3\Release\Project3.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
BIN
Project3/Release/Project3.iobj
Normal file
BIN
Project3/Release/Project3.iobj
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.ipdb
Normal file
BIN
Project3/Release/Project3.ipdb
Normal file
Binary file not shown.
7
Project3/Release/Project3.log
Normal file
7
Project3/Release/Project3.log
Normal file
|
@ -0,0 +1,7 @@
|
|||
Items.cpp
|
||||
main.cpp
|
||||
Generating code
|
||||
Previous IPDB not found, fall back to full compilation.
|
||||
All 365 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
Finished generating code
|
||||
Project3.vcxproj -> C:\Users\cody\OneDrive - SNHU\CS-210\Project3\Release\Project3.exe
|
BIN
Project3/Release/Project3.res
Normal file
BIN
Project3/Release/Project3.res
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/CL.command.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/CL.read.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/CL.write.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
2
Project3/Release/Project3.tlog/Project3.lastbuildstate
Normal file
2
Project3/Release/Project3.tlog/Project3.lastbuildstate
Normal file
|
@ -0,0 +1,2 @@
|
|||
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
|
||||
Release|Win32|C:\Users\cody\OneDrive - SNHU\CS-210\Project3\|
|
BIN
Project3/Release/Project3.tlog/link.command.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/link.read.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/link.write.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/rc.command.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/rc.command.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/rc.read.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/rc.read.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/Project3.tlog/rc.write.1.tlog
Normal file
BIN
Project3/Release/Project3.tlog/rc.write.1.tlog
Normal file
Binary file not shown.
BIN
Project3/Release/main.obj
Normal file
BIN
Project3/Release/main.obj
Normal file
Binary file not shown.
BIN
Project3/Release/vc142.pdb
Normal file
BIN
Project3/Release/vc142.pdb
Normal file
Binary file not shown.
104
Project3/inputfile.txt
Normal file
104
Project3/inputfile.txt
Normal file
|
@ -0,0 +1,104 @@
|
|||
Spinach
|
||||
Radishes
|
||||
Broccoli
|
||||
Peas
|
||||
Cranberries
|
||||
Broccoli
|
||||
Potatoes
|
||||
Cucumbers
|
||||
Radishes
|
||||
Cranberries
|
||||
Peaches
|
||||
Zucchini
|
||||
Potatoes
|
||||
Cranberries
|
||||
Cantaloupe
|
||||
Beets
|
||||
Cauliflower
|
||||
Cranberries
|
||||
Peas
|
||||
Zucchini
|
||||
Peas
|
||||
Onions
|
||||
Potatoes
|
||||
Cauliflower
|
||||
Spinach
|
||||
Radishes
|
||||
Onions
|
||||
Zucchini
|
||||
Cranberries
|
||||
Peaches
|
||||
Yams
|
||||
Zucchini
|
||||
Apples
|
||||
Cucumbers
|
||||
Broccoli
|
||||
Cranberries
|
||||
Beets
|
||||
Peas
|
||||
Cauliflower
|
||||
Potatoes
|
||||
Cauliflower
|
||||
Celery
|
||||
Cranberries
|
||||
Limes
|
||||
Cranberries
|
||||
Broccoli
|
||||
Spinach
|
||||
Broccoli
|
||||
Garlic
|
||||
Cauliflower
|
||||
Pumpkins
|
||||
Celery
|
||||
Peas
|
||||
Potatoes
|
||||
Yams
|
||||
Zucchini
|
||||
Cranberries
|
||||
Cantaloupe
|
||||
Zucchini
|
||||
Pumpkins
|
||||
Cauliflower
|
||||
Yams
|
||||
Pears
|
||||
Peaches
|
||||
Apples
|
||||
Zucchini
|
||||
Cranberries
|
||||
Zucchini
|
||||
Garlic
|
||||
Broccoli
|
||||
Garlic
|
||||
Onions
|
||||
Spinach
|
||||
Cucumbers
|
||||
Cucumbers
|
||||
Garlic
|
||||
Spinach
|
||||
Peaches
|
||||
Cucumbers
|
||||
Broccoli
|
||||
Zucchini
|
||||
Peas
|
||||
Celery
|
||||
Cucumbers
|
||||
Celery
|
||||
Yams
|
||||
Garlic
|
||||
Cucumbers
|
||||
Peas
|
||||
Beets
|
||||
Yams
|
||||
Peas
|
||||
Apples
|
||||
Peaches
|
||||
Garlic
|
||||
Celery
|
||||
Garlic
|
||||
Cucumbers
|
||||
Garlic
|
||||
Apples
|
||||
Celery
|
||||
Zucchini
|
||||
Cucumbers
|
||||
Onions
|
82
Project3/main.cpp
Normal file
82
Project3/main.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* Cody Cook
|
||||
2023/04/13
|
||||
CS-210 Project 3
|
||||
*/
|
||||
#include <iostream> // use cout and cin
|
||||
#include <vector> // for use in menuItems
|
||||
|
||||
#include "Items.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void menu()
|
||||
{
|
||||
unsigned int input = 0;
|
||||
Items Items;
|
||||
string search;
|
||||
|
||||
// create a vector of the menu items
|
||||
vector<string> menuItems = {
|
||||
"Check the purchase frequency of an item.", // input 1
|
||||
"Display the purchase frequency of all items.", // input 2
|
||||
"Display the purchase frequency of all items in a histogram.", // input 3
|
||||
"Exit." // input 4
|
||||
};
|
||||
|
||||
// loop until the user enters the exit input
|
||||
while (input != 4)
|
||||
{
|
||||
cout << "Corner Grocer: Inventory Menu\n\n";
|
||||
for (unsigned int i = 0; i < menuItems.size(); i++)
|
||||
{
|
||||
cout << c_red << i + 1 << c_normal << ". " << menuItems[i] << endl;
|
||||
}
|
||||
cout << endl
|
||||
<< "Enter your choice: " << c_red;
|
||||
cin >> input;
|
||||
cout << c_normal;
|
||||
|
||||
// if the user enters a non-integer
|
||||
if (cin.fail())
|
||||
{
|
||||
cin.clear(); // clear the error flag
|
||||
cin.ignore(1000, '\n'); // ignore the rest of the input
|
||||
input = 0; // set the input to 0
|
||||
}
|
||||
cout << endl;
|
||||
switch (input)
|
||||
{
|
||||
case 1:
|
||||
cout << "Enter an item you wish to check the purchase frequency: ";
|
||||
cout << c_red;
|
||||
cin >> search;
|
||||
cout << c_normal;
|
||||
Items.GetInventory(search);
|
||||
break;
|
||||
case 2:
|
||||
Items.PrintInventory(1);
|
||||
break;
|
||||
case 3:
|
||||
Items.PrintInventory(2);
|
||||
break;
|
||||
case 4:
|
||||
cout << "Goodbye!" << endl;
|
||||
break;
|
||||
default:
|
||||
cerr << "Invalid input. Please try again." << endl;
|
||||
break;
|
||||
}
|
||||
cout << endl;
|
||||
system("pause");
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// call the menu function
|
||||
menu();
|
||||
|
||||
// return successful
|
||||
return 0;
|
||||
}
|
14
Project3/resource.h
Normal file
14
Project3/resource.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Project3.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
BIN
Release/Project3.exe
Normal file
BIN
Release/Project3.exe
Normal file
Binary file not shown.
BIN
Release/Project3.pdb
Normal file
BIN
Release/Project3.pdb
Normal file
Binary file not shown.
104
Release/inputfile.txt
Normal file
104
Release/inputfile.txt
Normal file
|
@ -0,0 +1,104 @@
|
|||
Spinach
|
||||
Radishes
|
||||
Broccoli
|
||||
Peas
|
||||
Cranberries
|
||||
Broccoli
|
||||
Potatoes
|
||||
Cucumbers
|
||||
Radishes
|
||||
Cranberries
|
||||
Peaches
|
||||
Zucchini
|
||||
Potatoes
|
||||
Cranberries
|
||||
Cantaloupe
|
||||
Beets
|
||||
Cauliflower
|
||||
Cranberries
|
||||
Peas
|
||||
Zucchini
|
||||
Peas
|
||||
Onions
|
||||
Potatoes
|
||||
Cauliflower
|
||||
Spinach
|
||||
Radishes
|
||||
Onions
|
||||
Zucchini
|
||||
Cranberries
|
||||
Peaches
|
||||
Yams
|
||||
Zucchini
|
||||
Apples
|
||||
Cucumbers
|
||||
Broccoli
|
||||
Cranberries
|
||||
Beets
|
||||
Peas
|
||||
Cauliflower
|
||||
Potatoes
|
||||
Cauliflower
|
||||
Celery
|
||||
Cranberries
|
||||
Limes
|
||||
Cranberries
|
||||
Broccoli
|
||||
Spinach
|
||||
Broccoli
|
||||
Garlic
|
||||
Cauliflower
|
||||
Pumpkins
|
||||
Celery
|
||||
Peas
|
||||
Potatoes
|
||||
Yams
|
||||
Zucchini
|
||||
Cranberries
|
||||
Cantaloupe
|
||||
Zucchini
|
||||
Pumpkins
|
||||
Cauliflower
|
||||
Yams
|
||||
Pears
|
||||
Peaches
|
||||
Apples
|
||||
Zucchini
|
||||
Cranberries
|
||||
Zucchini
|
||||
Garlic
|
||||
Broccoli
|
||||
Garlic
|
||||
Onions
|
||||
Spinach
|
||||
Cucumbers
|
||||
Cucumbers
|
||||
Garlic
|
||||
Spinach
|
||||
Peaches
|
||||
Cucumbers
|
||||
Broccoli
|
||||
Zucchini
|
||||
Peas
|
||||
Celery
|
||||
Cucumbers
|
||||
Celery
|
||||
Yams
|
||||
Garlic
|
||||
Cucumbers
|
||||
Peas
|
||||
Beets
|
||||
Yams
|
||||
Peas
|
||||
Apples
|
||||
Peaches
|
||||
Garlic
|
||||
Celery
|
||||
Garlic
|
||||
Cucumbers
|
||||
Garlic
|
||||
Apples
|
||||
Celery
|
||||
Zucchini
|
||||
Cucumbers
|
||||
Onions
|
Loading…
Add table
Add a link
Reference in a new issue