You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
package model;
|
|
|
|
public class Weather {
|
|
private final String province;
|
|
private final String city;
|
|
private final String condition;
|
|
private final String temperature; // 实时温度
|
|
|
|
public Weather(String province, String city, String condition, String temperature) {
|
|
this.province = province;
|
|
this.city = city;
|
|
this.condition = condition;
|
|
this.temperature = temperature;
|
|
}
|
|
|
|
public String getProvince() { return province; }
|
|
public String getCity() { return city; }
|
|
public String getCondition() { return condition; }
|
|
public String getTemperature() { return temperature; }
|
|
|
|
// 用于排序,提取温度数字
|
|
public int getTempNum() {
|
|
try {
|
|
return Integer.parseInt(temperature.replaceAll("[^0-9]", ""));
|
|
} catch (Exception e) {
|
|
return Integer.MIN_VALUE;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "省份:" + province + " | 城市:" + city + " | 天气:" + condition + " | 实时温度:" + temperature;
|
|
}
|
|
}
|