package TianQiYuBao;
import com.imooc.weather.HourWeather;
import com.imooc.weather.WeatherUtils;
import com.imooc.weather.impl.WeatherUtilsImpl;
import java.util.List;
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
System.out.println("输入想要查询的天气:24小时。:三天。:七天。");
System.out.print("输入你的选择:");
Scanner scanner = new Scanner(System.in);
int i = scanner.nextInt();
System.out.println("你输入的是:"+i);
if (i == 24){
System.out.print("输入要查询的城市名称:");
String city = scanner.next();
WeatherUtils weatherUtils = new WeatherUtilsImpl();
List<HourWeather> weatherList = weatherUtils.w24h("553d41feff124ac6a2fce95fc0810eba",city);
//System.out.println(weatherList);
if (weatherList.size() == 0){
System.out.println("抱歉,未查询到您想要的数据。");
}else{
for (HourWeather hourWeather : weatherList){
String template = "%s月%s日%s时|%s|%s|%s|%s@";
String row = String.format(template,new String[]{
hourWeather.getMonth(),
hourWeather.getDay(),
hourWeather.getHour(),
hourWeather.getWindDirection(),
hourWeather.getWindPower(),
hourWeather.getWeather(),
hourWeather.getTemperature()
});
System.out.println(row);
}
}
}
}
}