Ask Question
18 March, 01:18

Write the definition of a class WeatherForecast that provides the following behavior (methods) : A method called set_skies that has one parameter, a String. A method called set_high that has one parameter, an int. A method called set_low that has one parameter, an int. A method called get_skies that has no parameters and that returns the value that was last used as an argument in set_skies. A method called get_high that has no parameters and that returns the value that was last used as an argument in set_high. A method called get_low that has no parameters and that returns the value that was last used as an argument in set_low. No constructor need be defined. Be sure to define instance variables as needed by your "get"/"set" methods.

+2
Answers (1)
  1. 18 March, 03:06
    0
    class WeatherForecast (object):

    skies = ""

    min = 0

    max = 0

    def get_skies (self):

    return self. skies

    def set_skies (self, value):

    self. skies = value

    def get_max (self):

    return self. max

    def set_max (self, value):

    self. max = value

    def get_min (self):

    return self. min

    def set_min (self, value):

    self. min = value

    def main ():

    obj1 = WeatherForecast ()

    obj1. set_skies ("Skies1")

    obj1. set_max (2)

    obj1. set_min (0)

    print ("Calling get_skies () : ", obj1. get_skies ())

    print ("Calling get_max () : ", obj1. get_max ())

    print ("Calling get_min () : ", obj1. get_min ())

    main ()

    Explanation:

    Inside the WeatherForecast class, initialize variables for skies, minimum and maximum. Define the getter and setter method for the necessary variables inside the WeatherForecast class. Create an object of the class WeatherForecast. Call the getter functions of the class and display the results. Finally call the main function to test the program.
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 method called set_skies 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