package?com.imooc.weather;
import?com.imooc.weather.impl.WeatherUtilsImpl;
import?sun.plugin.dom.exception.BrowserNotSupportedException;
import?java.util.List;
import?java.util.Scanner;
public?class?Application?{
????public?static?void?main(String[]?args)?{
????????System.out.println("查詢最近天氣預報");
????????System.out.println("輸入1:查詢未來24小時天氣預報");
????????System.out.println("輸入2:查詢未來3天天氣預報");
????????System.out.println("輸入3:查詢未來7天天氣預報");
????????System.out.print("請輸入您的選擇:");
????????Scanner?scanner=?new?Scanner(System.in);
????????int?i=?scanner.nextInt();
????????System.out.println("用戶輸入數字"+i);
????????if?(i==1){
????????????System.out.println("請輸入城市名稱查詢為24小時天氣預報");
????????????String?city=?scanner.next();
????????????WeatherUtils?weatherUtils?=new?WeatherUtilsImpl();
????????????List<HourWeather>?weatherList?=?weatherUtils.w24h("6196c9db162949e78158039af608da0c",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.getTemperature(),
????????????????????});
????????????????????System.out.println(row);
2022-05-27
把最上面自動引用的的包刪除了