hi guys ive come across a problem that i cant solve its probably easy but im new to java so some help would be appreciated
thanks.!! the question is about "class Date"

class Date

private variables

private int day, month, year

constructors

Date()
// post day = month = year = 0

Date(int dd, int mm, int yy)
// post, day = dd, month = mm; year = yy

accessor

boolean earlierThan(Date other)

question is i know the variables but how would i code the constructors and the accessor thanks

10-20-2011, 01:39 AM

Junky

Re: hello guys i need help im a newbie!!!!

Code:

// post, day = dd, month = mm; year = yy

That line of code is basically correct. All you need to do is make it legal Java syntax. So I don't understand your problem. As for accessor methods all they do is provide access to your private variables. Use setter methods to assign new values to the variables. Use getters to retrieve (return) the value of the variables. You will need one method per variable.

10-20-2011, 01:52 AM

andrewkay

Re: hello guys i need help im a newbie!!!!

k well thats the part i dont understand so was wondering what someone would code for that specific accessor thanks

Personally I have 2 issue with the above line. I hate code like that and would make 3 separate statements. Also, the default value of instance variables is 0 so that line of code is completely unnecessary.

Quote:

but what would i code for "boolean earlierThan(Date other)" would it be....