84.2k views
1 vote
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.

User Jacelyn
by
5.3k points

1 Answer

7 votes

Answer:

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;

}

}

Step-by-step 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.

User Lincolnfrias
by
5.4k points