-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (36 loc) · 1.05 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
#include "weather_client.hpp"
int main(int argc, char const *argv[])
{
static WeatherClient w = WeatherClient();
std::cout << "Welcome!" << std::endl;
std::cout << "Is the temperature output in Celsius or Fahrenheit? (C/F)" << std::endl;
bool isCelsius = false;
while (1)
{
std::string temp;
getline(std::cin, temp);
if (temp == "c" || temp == "C")
{
isCelsius = true;
break;
}
else if (temp == "f" || temp == "F")
break;
std::cout << "Incorrect input!" << std::endl;
}
while (1)
{
std::cout << "Please, enter the name City (enter q for exit)" << std::endl;
std::string city;
getline(std::cin, city);
if (city == "q")
break;
w.getWeatherData(city);
if (w.getIsSucess())
w.printWeatherData(isCelsius);
else
std::cout << "The city was entered incorrectly or a server error occurred" << std::endl;
std::cout << std::endl;
}
return 0;
}