Java1.创建一个代表天气对象的实体类 a)拥有私有属性:日期,地点,风速,温度,湿度 b)拥有属性的get,set公有方法
时间: 2024-05-29 13:11:42 浏览: 85
public class Weather {
private String date;
private String location;
private int windSpeed;
private int temperature;
private int humidity;
public Weather(String date, String location, int windSpeed, int temperature, int humidity) {
this.date = date;
this.location = location;
this.windSpeed = windSpeed;
this.temperature = temperature;
this.humidity = humidity;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public int getWindSpeed() {
return windSpeed;
}
public void setWindSpeed(int windSpeed) {
this.windSpeed = windSpeed;
}
public int getTemperature() {
return temperature;
}
public void setTemperature(int temperature) {
this.temperature = temperature;
}
public int getHumidity() {
return humidity;
}
public void setHumidity(int humidity) {
this.humidity = humidity;
}
}
阅读全文