Results 1 to 10 of 10
- 07-29-2011, 10:34 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 16
- Rep Power
- 0
Creating and implementing class for creating a calendar object
Hi, so I have to create and implement a class for creating calendar objects. Some of the behaviours that the class has to do is:
- Print a display for a given month and year
- Print a display for the current month
- Get the current date
- Set the current date
- Roll the calendar date forward or backward by a given number of days or months
- A toString() method.
I also have to provide a selection of constructors with default values for the variables.
Now.. I have absolutely, no f*****g clue of what to do. I don't even know where to start. Please, please, please, could somebody give me a nudge in the right direction of where to start?
Thanks in advance.
- 07-29-2011, 10:56 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Surprise: it has been done for you; read the API documentation for the Calendar and GregoreanCalendar classes.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-29-2011, 11:00 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 16
- Rep Power
- 0
Thanks for the reply JosAH. However, that doesn't really help. I know it's all there already, but I'm required to write out my own class myself.
- 07-29-2011, 11:07 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
First list the data the calendar class needs to hold.
Those are your attributes.
Provide a constructor that takes values to populate those attributes.
That list above is the list of methods it needs to provide.
Start with that. Then pick one of the methods above and try and code it.
- 07-29-2011, 11:12 AM #5
Member
- Join Date
- Jul 2011
- Posts
- 16
- Rep Power
- 0
Ok. so for my attributes, so far I know that I need an attribute for the current date, and an attribute for the 'first year'.
The constructors are what's confusing me the most to be honest. I don't understand how to actually create the calendar object.
- 07-29-2011, 11:28 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Do they want you to reinvent the wheel and implement your own Calendar class? If so, google for 'Zeller's congruence'; it has all the date functionality you'll need.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-29-2011, 11:31 AM #7
Member
- Join Date
- Jul 2011
- Posts
- 16
- Rep Power
- 0
Haha yeh, pretty much. But it's just to test our understanding of creating classes and objects and whatnot. But that doesn't mean I can't use methods from the Calendar and GregorianCalendar classes.
Regarding zeller's congruence, I am already quite familiar with it. But all that gives me is the first day of the month, and although that will help me down the track, I'm still quite far away from using it.
- 07-29-2011, 12:27 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-29-2011, 02:10 PM #9
Member
- Join Date
- Jul 2011
- Posts
- 16
- Rep Power
- 0
JosAH - Sorry, for the misunderstanding.. But still, my understanding of zeller's congruence doesn't matter at this point. Right now, I'm having trouble with starting off. E.g - what do I write for the various constructors of my calendar class, and how to write the different behaviours I outlined in the original post.
- 07-29-2011, 02:18 PM #10
Similar Threads
-
Help creating a calendar in Java
By bars225 in forum New To JavaReplies: 11Last Post: 06-18-2011, 09:16 PM -
how to initialize base class variable without creating object for that?
By kaka in forum New To JavaReplies: 3Last Post: 09-29-2010, 09:26 AM -
accessing fields from another class without creating an object
By johnnyjohn2009 in forum New To JavaReplies: 2Last Post: 03-08-2010, 10:29 AM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
Creating object of Type Object class
By venkatv in forum New To JavaReplies: 3Last Post: 07-17-2007, 03:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks