Skip to content

Instantly share code, notes, and snippets.

@apietras
Created October 18, 2016 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apietras/c6bbf65840dc018f1ade180defa27f87 to your computer and use it in GitHub Desktop.
Save apietras/c6bbf65840dc018f1ade180defa27f87 to your computer and use it in GitHub Desktop.
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