Bag  0.91
io_functions.cpp
Go to the documentation of this file.
1 
8 #include "io_functions.h"
9 
10 using namespace std;
11 
16 void printMenu(){
17  cout << "1) Print the size of the bag" << endl;
18  cout << "2) Add an item into the bag" << endl;
19  cout << "3) Remove an item from the bag" << endl;
20  cout << "4) Check for an item in the bag" << endl;
21  cout << "8) Display the bag" << endl;
22  cout << "9) Quit the program" << endl;
23 }
24 
30 int getInt(){
31  int intValue = 0;
32  string inputStr;
33  do{
34  getline(cin, inputStr);
35  stringstream(inputStr) >> intValue;
36  if(intValue < 1) cout << "ERROR - please enter a positive integer> ";
37  } while(intValue < 1);
38  return intValue;
39 }
40 
46 string getItem()
47 {
48  string item;
49  cout << "Enter the bag item> ";
50  getline(cin, item);
51  return item;
52 }
53