Skip to content

Commit

Permalink
Merge pull request #17 from Muhin007/wp-10
Browse files Browse the repository at this point in the history
wp-10 Убрана фабрика
  • Loading branch information
Muhin007 authored Jul 19, 2019
2 parents 2cb126e + 12adfdc commit 09a21f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.github.muhin007.iWeatherProvider.weatherAgregator;

import com.github.muhin007.iWeatherProvider.weatherAdaptor.Site;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.SiteSelector;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.aerisapi.WeatherAdaptorAerisapi;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.apixu.WeatherAdaptorApixu;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.worldweatheronline.WeatherAdaptorWorldweatheronline;
import com.github.muhin007.iWeatherProvider.weatherAdaptor.yandex.WeatherAdaptorYandex;

import java.util.Arrays;
import java.util.Scanner;

public class WeatherAggregator {
SiteSelector siteSelector = new SiteSelector();

private static volatile WeatherAggregator instance = null;

Expand All @@ -32,8 +33,10 @@ private void getCityName() {

public void AVGTemp() {
getCityName();
int[] temps = {siteSelector.getWeatherAdaptor(Site.YANDEX).getTemp(cityName), siteSelector.getWeatherAdaptor(Site.AERISAPI).getTemp(cityName),
siteSelector.getWeatherAdaptor(Site.APIXU).getTemp(cityName), siteSelector.getWeatherAdaptor(Site.WORLDWEATHERONLINE).getTemp(cityName)};
int[] temps = new int[]{new WeatherAdaptorYandex().getTemp(cityName),
new WeatherAdaptorAerisapi().getTemp(cityName),
new WeatherAdaptorApixu().getTemp(cityName),
new WeatherAdaptorWorldweatheronline().getTemp(cityName)};
double avgTemp = Arrays.stream(temps).sum() / temps.length;
System.out.println("Средняя температура в городе " + cityName + " : " + avgTemp + "C.");
}
Expand Down

0 comments on commit 09a21f5

Please sign in to comment.