Write the definition of a class Weather Forecast: Write the definition of a clas
ID: 3818576 • Letter: W
Question
Write the definition of a class Weather Forecast:
Write the definition of a class WeatherForecast that provides the following behavior (methods): A method called setSkies that has one parameter, a String. A method called setHigh that has one parameter, an int. A method called setLow that has one parameter, an int. A method called getSkies that has no parameters and that returns the value that was last used as an argument in setSkies. A method called getHigh that has no parameters and that returns the value that was last used as an argument in setHigh. A method called getLow that has no parameters and that returns the value that was last used as an argument in setLow. No constructor need be defined. Be sure to define instance variables as needed by your "get"/"set" methods-initialize all numeric variables to 0 and any String variables to the empty string.Explanation / Answer
class Weather{
String skies = "";
int high = 0;
int low = 0;
void setSkies(String skies)
{
this.skies = skies;
}
void setHight(int high)
{
this.high = high;
}
void setLow(int low)
{
this.low = low;
}
String getSkies()
{
return skies;
}
int getHigh()
{
return high;
}
int getLow()
{
return low;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.