119k views
3 votes
Worth 3 Points Write the definition of a public class WeatherForecast that provides the following behavior (methods) A method called setSkies that has one parameter, a string o A method called setHigh that has one parameter, an int A method called setLow that has one parameter, an int. o A method called getSkies that has no parameters and that returns the value that was last used as an argument in setSkies that was last used as an argument in setHigh was last used as an argument in setLow o A method called getHigh that has no parameters and that returns the value o A method called getLow that has no parameters and that returns the value that No constructor need be defined. Be sure to define instance variables as needed by your "getter"/"setter" methods-initialize all numeric variables to 0 and any String variables to the empty string 1

User Gwally
by
4.1k points

1 Answer

2 votes

Answer:

public class WeatherForecast {

private String sky = "";

private int highTemperature = 0;

private int lowTemperature = 0;

public void setSkies(String sky ){

this.sky = sky;

}

public void setHigh(int highTemperature){

this.highTemperature = highTemperature;

}

public void setLow(int lowTemperature){

this.lowTemperature = lowTemperature;

}

public String getSkies(){

return sky;

}

public int getHigh(){

return highTemperature;

}

public int getLow(){

return lowTemperature;

}

}

Step-by-step explanation:

- Three private variables are created to hold values.

- Since variables are private, three set methods are created to set the given values.

- Since variables are private, three get methods are created to return the values

User Elranu
by
4.9k points