1.)Write the definition of a class Counter containing: An instance variable name
ID: 3546867 • Letter: 1
Question
1.)Write the definition of a class Counter containing:
An instance variable named counter of type int .
A constructor that takes one int argument and assigns its value to counter
A method named increment that adds one to counter . It does not take parameters or return a value.
A method named decrement that subtracts one from counter . It also does not take parameters or return a value.
A method named get_value that returns the value of the instance variable counter .
2.)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.
Explanation / Answer
A method named decrement that subtracts one from counter . It also does not take parameters or return a value.
A method called get_high that has no parameters and that returns the value that was last used as an argument in set_high .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.