-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventory.hpp
More file actions
33 lines (30 loc) · 872 Bytes
/
Inventory.hpp
File metadata and controls
33 lines (30 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef INVENTORY_H
#define INVENTORY_H
#include <iostream>
#include <map>
// contains key map to inventory of store
// contains map of item name to item number
class Inventory
{
private:
// length of string for printing
size_t max_item_length = 0;
// map of item name to number
std::map<std::string, size_t> inventory;
public:
// constructor
Inventory(){}
// returns item number based on name
size_t& operator[](const std::string key);
// reads key value pairs from text file
void readInventory(std::string filename);
// prints map; used for debugging
void to_string();
// prints map in html; used for debugging
void to_stringHTML();
// returns ptr to inventory object; deprecated; replaced by reference
std::map<std::string, size_t>* inventory_ptr();
// returns reference to inventory
std::map<std::string, size_t>& get_inventory();
};
#endif