-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
117 lines (104 loc) · 2.34 KB
/
main.cpp
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
#include<fstream>
#include<vector>
#include"Hotspot.h"
#include"Hotspotlist.h"
#include "sortedlinklist.h"
#include<ostream>
#include<iostream>
#include<stdlib.h>
#include<cstdlib>
#include<limits>
using namespace std;
/*
commands
nearby lat long distance writefile
findbyid id writefile
findbyboro boro writefile
*/
int main (int argc , char * argv [])
{
if(argc!=2)
{
cout<<"Not enough arguments passed."<<endl;
}
ifstream in(argv[1]);
if(in.fail()!=true)
{
Hotspotlist x (in);
string input,boro;
int id;
float lat ,lon,dist;
while(true)
{
cout<<"Enter n for nearby, fid for findbyid , fbb for find by borough or E for exit "<<endl;
cin>>input;
if(input=="n")
{
cout<<"Enter your latittude"<<endl;
cin>>lat;
while(cin.fail())
{
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<<"Error , the value entered was invalid"<<endl;
cin>>lat;
}
cout<<"Enter your longitude"<<endl;
cin>>lon;
while(cin.fail())
{
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<<"Error , the value entered was invalid"<<endl;
cin>>lat;
}
cout<<"Enter the acceptible distance (miles) from you"<<endl;
cin>>dist;
while(cin.fail())
{
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<<"Error , the value entered was invalid"<<endl;
cin>>lat;
}
x.nearby(lat,lon,dist);
}
else if(input=="fid")
{
cout<<"Enter the id of the hotspot"<<endl;
cin>>id;
while(cin.fail())
{
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<<"Error , the value entered was invalid"<<endl;
cin>>id;
}
x.find_byId(id);
}
else if(input=="fbb")
{
cout<<"Enter the boro"<<endl;
cin>>boro;
while(boro!="QU" && boro!="MN" && boro!="BX" && boro!="SI" && boro!="BK")
{
cout<<"Error , the value entered was invalid"<<endl;
cin>>boro;
}
x.find_boro(boro);
}
else if (input=="E")
{
exit(1);
}
else
{
cout<<"Unrecognized input "<<input<<" options are n , fid or fbb (case sensitive)."<<endl;
}
}
}
else
{
cout<<"The file "<<argv[1]<<" could not be opened"<<endl;
}
}