-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeatherForecast.cpp
28 lines (22 loc) · 989 Bytes
/
WeatherForecast.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
#include "WeatherForecast.h"
#include "OpenWeatherMapService.h"
#include <iostream>
WeatherForecast::WeatherForecast(WeatherService* service) {
this->service = service;
}
void WeatherForecast::setWeatherService(WeatherService* service) {
this->service = service;
}
WeatherData WeatherForecast::getCurrentWeather(const Location& location) {
return service->getWeatherData(location);
}
WeatherForecastData WeatherForecast::getWeatherForecast(const Location& location) {
WeatherForecastData forecastData;
WeatherData currentWeather = service->getWeatherData(location);
forecastData.setCurrentWeather(currentWeather);
// Use the current weather location and the service to get hourly forecast
Location currentLocation = currentWeather.getLocation();
std::vector<WeatherData> hourlyForecast = service->getHourlyWeatherForecast(currentLocation);
forecastData.setHourlyForecast(hourlyForecast);
return forecastData;
}