forked from Daniel-Moraes1/Quote-Quest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
223 lines (211 loc) · 8.12 KB
/
main.cpp
File metadata and controls
223 lines (211 loc) · 8.12 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
#include <string>
#include <iostream>
#include "Quote.h"
#include<queue>
#include "AdjacencyList.h"
#include <chrono>
int main()
{
AdjacencyList list;
list.insertData();
std::cout << "loading quote quotient..." << std::endl;
std::cout << std::endl;
// reads in graph via text file to avoid having to insert into graph each time program is run
list.readEdges("graph.txt");
int input;
float sentimentVal;
std::string category;
while (true)
{
// Creates user interface
std::cout << "Welcome to \"Quote Quest\"!" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Please enter a number for your desired initial category:" << std::endl;
std::cout << "1) Love" << std::endl;
std::cout << "2) Life" << std::endl;
std::cout << "3) Inspiration" << std::endl;
std::cout << "4) Philosophy" << std::endl;
std::cout << "5) Humor" << std::endl;
std::cout << "6) God" << std::endl;
std::cout << "7) Truth" << std::endl;
std::cout << "8) Wisdom" << std::endl;
std::cout << "9) Happiness" << std::endl;
std::cout << "10) Hope" << std::endl;
std::cout << "11) Hate" << std::endl;
std::cout << "Enter 0 to exit the program" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> input;
switch (input) {
case 0:
exit(0);
case 1:
category = "love";
break;
case 2:
category = "life";
break;
case 3:
category = "inspiration";
break;
case 4:
category = "philisophy";
break;
case 5:
category = "humor";
break;
case 6:
category = "god";
break;
case 7:
category = "truth";
break;
case 8:
category = "wisdom";
break;
case 9:
category = "happiness";
break;
case 10:
category = "hope";
break;
case 11:
category = "hate";
break;
}
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Please enter a desired sentiment value (between -1 and 1):" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> sentimentVal;
Quote* quote = list.generateQuote(sentimentVal, category);
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Your quote is: " << "\"" << quote->getQuote() << "\"" << std::endl;
std::cout << "Category: " << quote->getCategory() << std::endl;
std::cout << "Sentiment Value: " << quote->getSentimentVal() << std::endl;
std::cout << "Author: " << quote->getAuthor() << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Would you like to generate another quote? (enter 1 or 2)" << std::endl;
std::cout << "1) Yes" << std::endl;
std::cout << "2) No" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> input;
if (input == 1)
{
continue;
}
else
{
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Please enter preferred method of related quote generation or if you want to get another quote (enter 1 or 2)" << std::endl;
std::cout << "1) BFS" << std::endl;
std::cout << "2) DFS" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> input;
std::queue<Quote*> queue;
if (input == 1)
{
// set start to the current time DFS starts to run
auto start = std::chrono::high_resolution_clock::now();
queue = list.BFS(quote);
// sets stop to the current time DFS ends
auto stop = std::chrono::high_resolution_clock::now();
// calculates the duration of the DFS method
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
std::cout << "----------------------------------------------" << std::endl;
std::cout << "The time it took for a BFS to complete was " << duration.count() << " microseconds" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
quote = queue.front();
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Your quote is: " << "\"" << quote->getQuote() << "\"" << std::endl;
std::cout << "Category: " << quote->getCategory() << std::endl;
std::cout << "Sentiment Value: " << quote->getSentimentVal() << std::endl;
std::cout << "Author: " << quote->getAuthor() << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
queue.pop();
// while loop to run throughout the whole queue containing our quotes stored via BFS
while (!queue.empty())
{
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Would you like to view the next quote or exit? (enter 1 or 2)" << std::endl;
std::cout << "1) Yes" << std::endl;
std::cout << "2) No" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> input;
if (input == 1)
{
quote = queue.front();
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Your quote is: " << "\"" << quote->getQuote() << "\"" << std::endl;
std::cout << "Category: " << quote->getCategory() << std::endl;
std::cout << "Sentiment Value: " << quote->getSentimentVal() << std::endl;
std::cout << "Author: " << quote->getAuthor() << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
queue.pop();
}
else if (input == 2)
{
break;;
}
else if (input == 3)
{
exit(0);
}
}
}
else if (input == 2)
{
// set start to the current time DFS starts to run
auto start = std::chrono::high_resolution_clock::now();
queue = list.DFS(quote);
// sets stop to the current time DFS ends
auto stop = std::chrono::high_resolution_clock::now();
// calculates the duration of the DFS method
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
std::cout << "----------------------------------------------" << std::endl;
std::cout << "The time it took for a DFS to complete was " << duration.count() << " microseconds" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
quote = queue.front();
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Your quote is: " << "\"" << quote->getQuote() << "\"" << std::endl;
std::cout << "Category: " << quote->getCategory() << std::endl;
std::cout << "Sentiment Value: " << quote->getSentimentVal() << std::endl;
std::cout << "Author: " << quote->getAuthor() << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
queue.pop();
// while loop to run throughout the whole queue containing our quotes stored via DFS
while (!queue.empty())
{
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Would you like to view the next quote or exit? (enter 1 or 2)" << std::endl;
std::cout << "1) Yes" << std::endl;
std::cout << "2) No" << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cin >> input;
if (input == 1)
{
quote = queue.front();
std::cout << "----------------------------------------------" << std::endl;
std::cout << "Your quote is: " << "\"" << quote->getQuote() << "\"" << std::endl;
std::cout << "Category: " << quote->getCategory() << std::endl;
std::cout << "Sentiment Value: " << quote->getSentimentVal() << std::endl;
std::cout << "Author: " << quote->getAuthor() << std::endl;
std::cout << "----------------------------------------------" << std::endl;
std::cout << std::endl;
queue.pop();
}
else if (input == 2)
{
exit(0);
}
}
}
}
}
return 0;
}