java.lang.ObjectWeather
public class Weather
A helper class that fetch weather status for a specific location
It uses "The Weather Underground Core" API.
class WeatherQuery { private Weather weather = new Weather("France", "Paris"); public exampleMethod() { double temperature = weather.getTemperature(); String windDirection = weather.getWindDirection(); int humidity = weather.getHumidity(); System.out.println("The current temperature in " + weather.getCity() + " is " + temperature + " degrees"); } }
Constructor Summary | |
---|---|
Weather()
construct an object to get local weather status. |
|
Weather(java.lang.String country,
java.lang.String city)
Construct an object to get weather status in a specific city. |
Method Summary | |
---|---|
java.lang.String |
getCity()
get the city name. |
java.lang.String |
getCountry()
get the country name. |
int |
getHumidity()
Fetch the current humidity. |
double |
getPressure()
Fetch the current atmospheric air pressure in hectopascal (hPa). |
double |
getTemperature()
Fetch the current temperature in Celsius. |
java.lang.String |
getWindDirection()
Fetch the direction of the wind. |
double |
getWindSpeed()
Fetch the current speed of the wind in km/h. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Weather()
public Weather(java.lang.String country, java.lang.String city)
country
- the country namecity
- the city nameMethod Detail |
---|
public double getTemperature()
public double getWindSpeed()
public java.lang.String getWindDirection()
public int getHumidity()
public double getPressure()
public java.lang.String getCity()
public java.lang.String getCountry()