Java OOP GUIDE / WORK DATE CLASS Topics
TASK –
PART 1 – DATE CLASS: INSTANCE VARIABLES
It has three private
instance variables:
Note: All
three instance variables should probably be integers for convenience. TASK –
PART 2 – DATE CLASS: CONSTRUCTOR
Pre-condition:
You can assume that the variables provided as parameters are a legal date. TASK –
PART 3 – DATE CLASS: GET METHODS Include
the following get methods:
TASK –
PART 4 – DATE CLASS: MORE DATE FORMATS Also include a way to get the Date in the six common
formats below. You can create six
different methods or one method that gets a parameter indicating which format
is desired.
Note: In
Canada, when using numeric formats, we are encouraged to use the
international format. This format is
also alpha numerically sortable which is nice if used in filenames. TASK –
PART 5 – DATE CLASS: ANOTHER INSTANCE VARIABLE Add another
instance variable of type String called separator. The constructor should set it to the hyphen
“-“ by default. Provide a get
method for the separator instance variable. Provide a setSeparator(String
s) method to change the separator. Change your getMethods in the previous parts to use the separator
specified in the instance variable instead of only using the hyphen (“-“). TASK –
PART 6 – TESTING In
a Tester class, try creating a few Date objects. Test each method. Output to screen all of the different
formats. |
||||||||||||
|