-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
106 lines (81 loc) · 1.71 KB
/
Main.cpp
File metadata and controls
106 lines (81 loc) · 1.71 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
#include <iostream>
#include <string>
#include <fstream>
#include <iterator>
#include <vector>
#include <stack>
#include "FileOperations.h"
#include "Route.h"
#include "GraphFunctions.h"
using namespace std;
int main(int argc, char* argv[]){
string citiesFilename;
string routesFilename;
string outputFilename;
string origin;
string destination;
string preference;
bool biPreference;
if(argc > 1){
citiesFilename = argv[1];
}
else{
cout << "Enter filename containing cities: ";
cin >> citiesFilename;
}
if(argc > 2){
routesFilename = argv[2];
}
else{
cout << "Enter filename containing routes: ";
cin >> routesFilename;
}
if(argc > 3){
outputFilename = argv[3];
}
else{
cout << "Enter filename for output (.html): ";
cin >> outputFilename;
}
if(argc > 4){
origin = argv[4];
}
else{
cout << "Origin: ";
cin >> origin;
}
if(argc > 5){
destination = argv[5];
}
else{
cout << "Destination: ";
cin >> destination;
}
if(argc > 6){
preference = argv[6];
}
else{
cout << "Enter a preference (fastest/cheapest): ";
cin >> preference;
}
if(preference.compare("cheapest") == 0){
biPreference = true;
}
else if(preference.compare("fastest") == 0){
biPreference = false;
}
else{
cout << "Invalid entry";
return 0;
}
Graph graph(citiesFilename, routesFilename);
if(graph.getCity(origin) == NULL || graph.getCity(destination) == NULL){
cout << "Invalid entry" << endl;
return 0;
}
graph.Dijkstras(origin,biPreference);
stack<Location*> cityStack = graph.cityStacker(destination);
stack<Route*> routeStack = graph.routeStacker(destination, biPreference);
outputGenerator(outputFilename.c_str(), cityStack, routeStack, biPreference);
return 0;
}