This repository was archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject4_Bugaj.cpp
More file actions
118 lines (103 loc) · 4.52 KB
/
project4_Bugaj.cpp
File metadata and controls
118 lines (103 loc) · 4.52 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
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
108
109
110
111
112
113
114
115
116
117
118
#pragma once
// project4_Bugaj.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "hashtable.h"
#include "student.h"
#include "Slot.h"
#include <string>
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
hashtable<student> table;
//random comment
//random comment2
string choice = "";
//menu options loop
while (choice != "Q") {
cout << "Options" << "\n"<<
"(I)nsert \n"<<
"(D)elete \n"<<
"(S)earch \n"<<
"(Q)uit \n";
getline(cin, choice);
if (choice == "I") {
//generates random uid's
int uidGen = (rand() * 503);
string f, l, m, g;
cout << "First Name: \n";
getline(cin, f);
cout << "Last Name: \n";
getline(cin, l);
cout << "Major:(i.e. CS, CEG, EE) \n";
getline(cin, m);
cout << "Grade:(F)resh, (S)oph, (J)unior, (Se)nior \n";
getline(cin, g);
//converts to year to pass to student constructor
year y;
if (g == "F") {
y = freshman;
}
else if (g == "S") {
y = sophmore;
}
else if (g == "J") {
y = junior;
}
else if (g == "Se") {
y = senior;
}
else {
cout << "Grade invalid" << endl;
}
student temp(uidGen, f, l, m, y);
bool ins = table.insert(uidGen, temp, 0);
if (ins) {
cout << "Inserted" << endl;
}
else {
cout << "Insertion incomplete" << endl;
}
}
else if (choice == "D") {
cout << "Enter Key to be Removed:" << endl;
string key;
getline(cin,key);
//to int conversion
int val = atoi(key.c_str());
bool del = table.remove(val);
if (val) {
cout << "Deleted" << endl;
}
else {
cout << "item not found" << endl;
}
}
else if (choice == "S") {
student f;
cout << "Enter key:" << endl;
string key;
getline(cin, key);
int val = atoi(key.c_str());
bool found = table.find(val, f);
if (found) {
cout << "Student Found:" << endl;
cout << f << endl;
}
else {
cout << "Student not Found" << endl;
}
}
else if(choice == "Q") {
cout << "Exiting";
}
else {
cout << "Invalid request \n";
cout << "Please enter 'I', 'D', 'S', or 'Q' \n";
}
}
return 0;
}