Ask Question
2 November, 10:54

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. 2 November, 12:47
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers