This site requires JavaScript, please enable it in your browser!
Greenfoot back
Nosson1459
Nosson1459 wrote ...

2016/12/19

WeatherGrabber

Nosson1459 Nosson1459

2016/12/19

#
How do/can I use the information from Weather(Grabber) (I got it from importing a class in Greenfoot under the "Edit" menu)?
Nosson1459 Nosson1459

2016/12/20

#
"with no replies"
Nosson1459 Nosson1459

2016/12/21

#
Can't anybody around here answer this question (I guess not)?!
danpost danpost

2016/12/21

#
Nosson1459 wrote...
How do/can I use the information from Weather(Grabber)
I do not really get the question -- you can use the information however you please.
Nosson1459 Nosson1459

2016/12/22

#
What should the coding be for getting/using the information? Could you give an example?
danpost danpost

2016/12/22

#
Nosson1459 wrote...
What should the coding be for getting/using the information? Could you give an example?
There is an example use of it at the beginning of the Weather class.
Nosson1459 Nosson1459

2016/12/22

#
How do I type in my country and city that the WeatherGrabber will recognize it, it just says String country and String city so I can make that string be equal to anything but then it won't work. Doing this:
private WeatherGrabber weatherGrabber = new WeatherGrabber("Hello", "danpost");
won't work but there won't be any syntax errors, so what should I type in as my country and city (that will be recognized)?
Nosson1459 Nosson1459

2016/12/22

#
This is what I got with the example in Weather:
Exception in thread "Thread-63" java.lang.RuntimeException: Can not find weather information for Paris, France. Please check spelling or try another location
	at weather.util.WeatherGrabber.getWeatherStation(WeatherGrabber.java:102)
	at weather.util.WeatherGrabber.fetchData(WeatherGrabber.java:69)
	at weather.util.WeatherGrabber.access$000(WeatherGrabber.java:20)
	at weather.util.WeatherGrabber$1.run(WeatherGrabber.java:62)
	at java.lang.Thread.run(Thread.java:745)
java.lang.RuntimeException: Can not find weather information for Paris, France. Operation timed out.
	at weather.util.WeatherGrabber.getDataset(WeatherGrabber.java:117)
	at Weather.getTemperature(Weather.java:72)
	at WeatherQuery.exampleMethod(WeatherQuery.java:24)
	at WeatherQuery.act(WeatherQuery.java:19)
	at greenfoot.core.Simulation.actActor(Simulation.java:604)
	at greenfoot.core.Simulation.runOneLoop(Simulation.java:562)
	at greenfoot.core.Simulation.runContent(Simulation.java:221)
	at greenfoot.core.Simulation.run(Simulation.java:211)

Here's WeatherQuery:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class WeatherQuery here.
 * 
 * @author amjad
 * @version 2.0
 */
public class WeatherQuery extends Actor
{
    private Weather weather = new Weather("France", "Paris");
    /**
     * Act - do whatever the WeatherQuery wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        exampleMethod();
    }    

    public void 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");
        setImage(new GreenfootImage("The current temperature in " + weather.getCity() + " is " + temperature + " degrees", 14, null, null));
    }
}
I'm not in Paris, but I copied the code out of Weather to see if it will work.
danpost danpost

2016/12/22

#
I got the same thing. It may be that all this discussion is for naught. Apparently, the link to the data is broken for some reason. Whether this is temporary or permanent, I cannot say.
Nosson1459 Nosson1459

2016/12/22

#
danpost wrote...
I got the same thing.
At least it's not just me.
You need to login to post a reply.