Ask Question
3 March, 14:43

Write the definition of a class WeatherForecast that provides the following behavior (methods):

a. A method called setSkies that has one parameter, a String.

b. A method called setHigh that has one parameter, an int.

c. A method called setLow that has one parameter, an int.

d. A method called getSkies that has no parameters and that returns the value that was last used as an argument in setSkies.

e. A method called getHigh that has no parameters and that returns the value that was last used as an argument in setHigh.

f. A method called getLow that has no parameters and that returns the value that was last used as an argument in setLow.

+3
Answers (1)
  1. 3 March, 15:30
    0
    Following is the definition of class WeatherForecast:

    public class WeatherForecast

    {

    //declare variables

    private int low, high;

    private String skies;

    //set methods

    public void setSkies (String sks)

    {

    this. skies = sks;

    }

    public void setHigh (int hgh)

    {

    this. high = hgh;

    }

    public void setLow (int lw)

    {

    this. low = lw;

    }

    //get methods

    public String getSkies ()

    {

    return skies;

    }

    public int getHigh ()

    {

    return high;

    }

    public int getLow ()

    {

    return low;

    }

    }

    Explanation:

    Here three set methods i. e. setSkies (), setHigh () and setLow () are used to set the values for variables skies, high and low.

    Get methods i. e. getSkies (), getHigh () and getLow () are used to get the values stored in these variables.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the definition of a class WeatherForecast that provides the following behavior (methods): a. A method called setSkies that has one ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers