-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
225 lines (198 loc) · 8.19 KB
/
main.cpp
File metadata and controls
225 lines (198 loc) · 8.19 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include "heap.h"
#include "JeopardyMap.h"
#include <fstream>
#include <iostream>
#include <map>
using namespace std;
// read for jeopardy or double jeopardy, money value, questions, and answers
vector<Question> ReadTSV(string file)
{
vector<Question> JeopardyVector;
ifstream myFile;
myFile.open(file);
int test = 0;
// 9 categories
string round;
string value;
int moneyValue;
string dailyDouble;
string category;
string comments;
string question;
string answer;
string airDate;
string notes;
string line;
// take out first line
getline(myFile, line);
// push values into Question object vector
while (myFile.good() && test != 100000)
{
getline(myFile, round, '\t');
getline(myFile, value, '\t');
moneyValue = stoi(value);
getline(myFile, dailyDouble, '\t');
getline(myFile, category, '\t');
getline(myFile, comments, '\t');
getline(myFile, question, '\t');
getline(myFile, answer, '\t');
getline(myFile, line);
//cout << value << " | " << dailyDouble << ", " << question << " | " << answer << endl;
//filter out daily doubles since they cause inconsistincies with moneyValues
if (dailyDouble == "no")
{
JeopardyVector.push_back(Question(moneyValue, question, answer));
test++;
}
//cout << endl;
}
return JeopardyVector;
}
int main()
{
vector<Question> JeopardyVector = ReadTSV("master_season1-35.tsv");
int correct = 0;
//choose a data structure
cout << "JEOPARDY STUDY TOOL: CHOOSE A DATA STRUCTURE" << endl << "1. Heap" << endl << "2. Map" << endl;
int menuChoice, dataStructure, option, answer, stat;
cin >> dataStructure;
//heap
if (dataStructure == 1) {
//make heap
Heap heap(JeopardyVector.size());
heap.makeHeap(JeopardyVector);
//study mode or stats
cout << "JEOPARDY STUDY TOOL: MODE" << endl << "1. Study Mode" << endl << "2. My Stats" << endl << "3. Quit" << endl;
cout << endl;
cin >> menuChoice;
while (menuChoice != 3) {
//study mode
if (menuChoice == 1) {
cout << "STUDY MODE: CHOOSE ONE" << endl << "1. Read Question" << endl << "2. Advance Level" << endl << "3. Back" << endl;
cout << endl;
int option;
cin >> option;
while (option != 3) {
//read question
if (option == 1) {
Question q = heap.getQuestion();
cout << "Difficulty: " << q.getMoneyVal() << endl << q.getQuestion() << "?" << endl;
cout << "Press Any Button To Display Answer" << endl;
char answer;
cin >> answer;
cout << q.getAnswer() << endl;
cout << "Was Your Answer Correct?" << endl << "1. Yes" << endl << "2. No" << endl;
cin >> stat;
if (stat == 1) {
correct++;
}
if (stat == 2) {
correct = 0;
}
//3 consecutive correct answers advances level
if (correct == 3) {
heap.advanceLevel(heap.getMin().getMoneyVal(), 0);
correct = 0;
}
}
//advance level
else if (option == 2) {
heap.advanceLevel(heap.getMin().getMoneyVal(), 0);
cout << "New Level: " << heap.getMin().getMoneyVal() << endl;
correct = 0;
}
//print choices again: read or advance (heap)
cout << "STUDY MODE: CHOOSE ONE" << endl << "1. Read Question" << endl << "2. Advance Level" << endl << "3. Back" << endl;
cin >> option;
}
}
//my stats
else if (menuChoice == 2) {
cout << "Correct Answers: " << correct << endl << "Level: " << heap.getMin().getMoneyVal() << endl;
}
//print choices again: study mode or stats (heap)
cout << "JEOPARDY STUDY TOOL: MODE" << endl << "1. Study Mode" << endl << "2. My Stats" << endl << "3. Quit" << endl;
cin >> menuChoice;
}
}
else if (dataStructure == 2) {
JeopardyHashTable Map;
//make map with hashtable
for (int i = 0; i < JeopardyVector.size(); i++) {
int key = JeopardyVector[i].getMoneyVal();
Question q = JeopardyVector[i];
Map.insertQuestion(key, q);
}
//study mode or stats
cout << "JEOPARDY STUDY TOOL: MODE" << endl << "1. Study Mode" << endl << "2. My Stats" << endl << "3. Quit" << endl;
cout << endl;
cin >> menuChoice;
int currentVal = 0;
while (menuChoice != 3) {
if (!Map.checkLevel(currentVal)) {
currentVal += 100;
continue;
}
if (menuChoice == 1) {
cout << "STUDY MODE: CHOOSE ONE" << endl << "1. Read Question" << endl << "2. Advance Level" << endl << "3. Decrease Level" << endl << "4. Back " << endl;
cout << endl;
int option;
cin >> option;
while (option != 4) {
if (option == 1) {
Question q = Map.getQuestion(currentVal);
cout << "Difficulty: " << q.getMoneyVal() << endl << q.getQuestion() << "?" << endl;
cout << "Press Any Key To Display Answer" << endl;
char answer;
cin >> answer;
cout << q.getAnswer() << endl;
cout << "Was Your Answer Correct?" << endl << "1. Yes" << endl << "2. No" << endl;
cin >> stat;
if (stat == 1) {
correct++;
}
if (stat == 2) {
correct = 0;
}
}
else if (option == 2) {
if (currentVal + 100 < 5000) {
currentVal += 100;
correct = 0;
}
else {
cout << "At Max Level" << endl;
correct = 0;
}
cout << "New level: " << currentVal << endl;
}
else if (option == 3) {
if (currentVal - 100 >= 0) {
currentVal -= 100;
correct = 0;
}
else {
cout << "At Lowest Level" << endl;
correct = 0;
}
cout << "New level: " << currentVal << endl;
}
if (correct == 3) {
currentVal += 100;
correct = 0;
}
cout << "STUDY MODE: CHOOSE ONE" << endl << "1. Read Question" << endl << "2. Advance Level" << endl << "3. Decrease Level" << endl << "4. Back" << endl;
cin >> option;
}
}
else if (menuChoice == 2) {
cout << "Correct Answers: " << correct << endl << "Level: " << currentVal << endl;
}
//study mode or stats
cout << "JEOPARDY STUDY TOOL: MODE" << endl << "1. Study Mode" << endl << "2. My Stats" << endl << "3. Quit" << endl;
cout << endl;
cin >> menuChoice;
}
}
return 0;
}