First of all this excercise looks way bigger than it is! It is just spread out point-by-point.
1) Create a class called Today.
2) In class scope create two private integer variables
called temp and humidity and one
String variable called dayType
.
3) Initialize these variables in a no-arg constructor
with values consistent with a cool,
cloudy and humid day.
4) Create a method called getDayType( ) that takes
a String argument and returns a
String value representing
the type of day.
5) Create a main method where the Today class is instantiated.
6) Call the method off the Today object reference
(via the dot operator) from within the
output of a System.out.println
statement.
// i.e System.out.println( "The type of day is " + todayObjRef.getDayType( ));
7) From within another System.out.println statement
print to console the temperature and
the humidity.
You can do all this with what we covered last
week! Remember, everything is in the scope
of the class including the variables, constructors
and methods. Also recall, main is just
another method. The constructor, your methods
and the main method will each have their
own scope within the class.
Table of class members
class | Today |
variables
|
temp
humidity dayType |
constructor | Today( ) |
methods
|
main( )
getDayType( ) |