Uni Programing Help

Soldato
Joined
11 Apr 2003
Posts
4,218
Location
Notts
No, im not asking anyone to do my work for me before you ask! I have been asked to:
Code:
This part of the assignment is based on writing and testing a small class to
represent dates.

Your report should contain an annotated copy of the source code, along
with description of the steps that you used to test your program.

• Write a class declaration for Date, representing a Date as day, month,
and year. Use appropriate access control.

• Write a method void set(int d, int m, int y) which sets a Date
to a particular value.

• Write a member function called output which displays the value of a
Date in suitable form.

• Write member functions to add and subtract years and months from a
Date

• Write member functions tomorrow() and yesterday() that add or
subtract one day from a Date. Take care to handle the beginning and
end of months and years correctly.

• Write a member function that converts a Date into the number of days
before/after the first of January 1900. Use this function to calculate
your age in days.

Note that your marks for this section will also depend on the quality
of your code, in terms of comments, layout, naming conventions, and other
stylistic points.

So far I have the basic system in place, I am able to input a date, which will be written to an int, and then I return the inputed values.

Reading this, I do not see that I have to create an entire calendar (Nor do I know how!) However I was just wondering if you would say the same, and wheter or not people think it would be ok to import a Calendar class for use in my program, to corectly return dates, allow me to add and subtract days/months/years etc.

If yes, does anyone know where I would find Calendar.Java as my searches simply return descriptions about the class, but not the actual Calendar.Java class...

Thanks :)
 
Last edited:
im not 100pc sure what you're trying to do but if you wanna cover the whole year with these dates why not

My_DateClass calender[12][31];

access 22 of january - calender[0][22].output()

(c++ btw, i dont know java)
 
sam83uk said:
im not 100pc sure what you're trying to do but if you wanna cover the whole year with these dates why not

My_DateClass calender[12][31];

access 22 of january - calender[0][22].output()

(c++ btw, i dont know java)
Yeah I was thinking of creatin an array, however I would have to write a portion of calendar in order to account for gap years
 
Spuds said:
To use the Calandar method you need to import java.util.Calandar

The documentation for it can be found here
Looking at the op, that's not actually needed. Good to see use of the api though :).

Btw jcb, are you using Eclipse yet?
 
Back
Top Bottom