mirror of
https://github.com/didyouexpectthat/cs-210.git
synced 2024-12-22 03:01:13 -08:00
53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
/* 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
|
|
};
|