-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (38 loc) · 1.05 KB
/
main.cpp
File metadata and controls
45 lines (38 loc) · 1.05 KB
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
/*
Skeleton code for linear hash indexing
*/
#include <string>
#include <ios>
#include <fstream>
#include <vector>
#include <string>
#include <string.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <cmath>
#include "classes.h"
using namespace std;
int main(int argc, char* const argv[]) {
// Create the index
LinearHashIndex emp_index("EmployeeIndex.bin");
emp_index.createFromFile("Employee.csv");
// Loop to lookup IDs until user is ready to quit
string input;
while (true) {
cout << "Enter an employee ID to look up: ";
cin >> input;
if (input == "quit") {
break;
}
int id = stoi(input);
Record record = emp_index.findRecordById(id);
if (record.id == -1) {
cout << "Employee not found" << endl;
} else {
// cout << "Employee found: " << record.id << ", " << record.name << ", " << record.bio << endl;
record.print();
}
}
return 0;
}