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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include "HashTab.h"
using namespace std;
void runPrompt();
void add(string f, string l, string id,
string c, string m);
void rem(string cid);
void print();
void error(string s);
HashTab* hashtab;
//this is where i will store the string tokens
string strarray[10];
int main()
{
cout << "debug me" << endl;
runPrompt();
}
void runPrompt()
{
string input;
int index;
while(input != "quit")
{
index = 0;
cout << "set> ";
//get the input and split into iss stream
getline(cin,input);
istringstream iss(input);
while(iss)
{
//gather strings delimited by ' ' and store in array
//index starts at 0, so increment after
iss >> strarray[index];
index++;
}
if(input.find("add") != string::npos)
{
//add customer id, first name, last name
//strarray[0] = 'add'
//[1] = fname, [2] = lname, [3] = id
//[4] = classyear, [5] = major
add(strarray[1], strarray[2], strarray[3],
strarray[4], strarray[5]);
}
if(input.find("remove") != string::npos)
{
//remove
//strarray[0] = remove
//[1] = id
rem(strarray[1]);
}
if(input.find("print") != string::npos)
{
print();
}
if(input.find("quit") != string::npos)
{
//free up space
break;
}
if(input.find("quit") == string::npos && input.find("print") == string::npos
&& input.find("remove") == string::npos && input.find("add") == string::npos)
{
error(input);
}
}
}
void print()
{
}
void add(string f, string l, string id, string c, string m)
{
hashtab->addelm(f, l, id, c, m);
}
void rem(string num)
{
}
void error(string input)
{
cout << "Error! Command not found: " << input <<endl;
}
|