Create a gist now

Instantly share code, notes, and snippets.

@apietras /Weather.java Secret
Created Oct 18, 2016

KobietydoKodu: Tygodniowe Wyzwanie Programistyczne - zadanie #5 - początkujący - cz I
import lombok.Data;
@Data
public class Weather {
Double chanceOfRain;
Double maxTemperature;
Integer pressure;
Double windSpeed;
String city;
}
public class WeatherForecastService {
public static Weather getForecast(String city) {
Weather weather = new Weather();
weather.setCity(city);
weather.setChanceOfRain(100.0 * Math.random());
weather.setMaxTemperature(35.0 * Math.random());
weather.setPressure(950 + (int) (100.0 * Math.random()));
weather.setWindSpeed(100.0 * Math.random());
return weather;
}
}
public class WeatherTeller {
public static String CITY = "Warsaw";
public void tellWeather() {
Weather weather = WeatherForecastService.getForecast(CITY);
System.out.printf("Weather for %s: max temperature: %f C, chance of rain: %f %%, wind speed: %d km/h, preassure: %f hPa", weather.getCity(), weather.getMaxTemperature(), weather.getChanceOfRain(), weather.getWindSpeed(), weather.getPressure());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment