97 lines
1.7 KiB
Java
97 lines
1.7 KiB
Java
package eirb.pg203;
|
|
|
|
import java.time.Instant;
|
|
import java.util.concurrent.locks.Condition;
|
|
|
|
class WeatherData {
|
|
enum Condition {
|
|
SUNNY("☀️"),
|
|
PARTIAL("🌤"),
|
|
CLOUDY("☁️"),
|
|
RAINY("🌧"),
|
|
ERROR("E");
|
|
|
|
private String desc;
|
|
Condition(String desc) { this.desc = desc; }
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.desc;
|
|
}
|
|
}
|
|
|
|
private City city;
|
|
private Instant date;
|
|
private float temp;
|
|
private Condition condition; // cloudly, sunny ...
|
|
private float windSpeed;
|
|
private float windDirection;
|
|
|
|
WeatherData(City city, Instant date, float temp, float windSpeed, float windDirection, Condition condition) {
|
|
this.city = city;
|
|
this.date = date;
|
|
this.temp = temp;
|
|
this.condition = condition;
|
|
this.windSpeed = windSpeed;
|
|
this.windDirection = windDirection;
|
|
}
|
|
|
|
public City getCity() {
|
|
return city;
|
|
}
|
|
|
|
public Instant getDate() {
|
|
return date;
|
|
}
|
|
|
|
public Condition getCondition() {
|
|
return condition;
|
|
}
|
|
|
|
public float getTemp() {
|
|
return temp;
|
|
}
|
|
|
|
public float getWindSpeed() {
|
|
return windSpeed;
|
|
}
|
|
|
|
public float getWindDirection() {
|
|
return windDirection;
|
|
}
|
|
|
|
public void setCity(City city) {
|
|
this.city = city;
|
|
}
|
|
|
|
public void setDate(Instant date) {
|
|
this.date = date;
|
|
}
|
|
|
|
public void setCondition(Condition condition) {
|
|
this.condition = condition;
|
|
}
|
|
|
|
public void setTemp(float temp) {
|
|
this.temp = temp;
|
|
}
|
|
|
|
public void setWindSpeed(float windSpeed) {
|
|
this.windSpeed = windSpeed;
|
|
}
|
|
|
|
public void setWindDirection(float windDirection) {
|
|
this.windDirection = windDirection;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("%05.2f° %s %05.2fkm/h %06.2f°",
|
|
this.getTemp(),
|
|
this.getCondition().toString(),
|
|
this.getWindSpeed(),
|
|
this.getWindDirection()
|
|
);
|
|
}
|
|
}
|