Here's a question i got in my assignment...
Create a method with signature
public String testWindDirection()
that creates a local object of type WeatherReport using the constructor with no parameters,
and returns its initial wind direction, e.g "ESE"
I createrd it here...
public class Reporter
{
private WeatherStation ws;
private WeatherReport wr;
private WeatherStation temperature;
private WeatherReport winddir;
/** Constructor for objects of class Report
*/
public Reporter()
{
ws = new WeatherStation("Tropical");
wr = new WeatherReport();
}
/** Returns initial temperature value
*/
public int testTemperature()
{
temperature = ws;
return temperature.getTemperature();
}
/** Comment...
*/
public String testWindDirection()
{
this.winddir = wr;
return winddir.getWindDirection();
}
/**
* Constructor for objects of class Report
* @param where Location?
*/
public Reporter(String where)
{
ws = new WeatherStation(where);
wr = new WeatherReport();
}
}
This runs, but doesn't produce the exact result. Here is the error i get when it is tested...
The output should have been:
WeatherStation in TROPICAL zone created
WeatherReport for Mt Erebus created
Test 2
WeatherReport for Mt Erebus created
Default WeatherReport has wind direction of SThis is what was actually produced:
WeatherStation in TROPICAL zone created
WeatherReport for Mt Erebus created
Test 2
Default WeatherReport has wind direction of S
Can someone see something wrong in my code?
It doesn't produce another WeatherReport for Mt Erebus.