-
-
Save apietras/c6bbf65840dc018f1ade180defa27f87 to your computer and use it in GitHub Desktop.
KobietydoKodu: Tygodniowe Wyzwanie Programistyczne - zadanie #5 - początkujący - cz I
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.Data; | |
@Data | |
public class Weather { | |
Double chanceOfRain; | |
Double maxTemperature; | |
Integer pressure; | |
Double windSpeed; | |
String city; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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