mirror of
https://github.com/didyouexpectthat/cs-210.git
synced 2025-08-21 17:53:18 -07:00
Add files via upload
This commit is contained in:
parent
69f200c559
commit
616970a7f6
10 changed files with 778 additions and 0 deletions
52
Items.h
Normal file
52
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
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue