Results 1 to 7 of 7
- 09-06-2010, 07:29 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
plz help me with this class, calendar
Hi. I'm new to oop. I'm programming a calendar which has several classes. But i'm stuck in one the classes. i got so helpless with that. is the any one who can guide me how to write this class?
I've also attached the pdf file.
appreciate it.
Specification for the Calendar class:
Fields/Members:
• Event[] events – An array holding the scheduled events. Make it size 10 (small to support easy testing).
• int numEvents – The number of events currently scheduled.
Constructors:
• Calendar() – This constructor must initialize the fields of the new Calendar object: creating a 10-element Event[] and setting numEvents to 0 (zero).
Methods:
• void addEvent(int year, int month, int day, int hour, String activity) – Create and add an Event instance to the associated Calendar.
• void addEvent(Event event) – Just add the Event object to the calendar.
• void removeEvent(int year, int month, int day, int hour, String activity)– Remove (all) Event objects in the associated Calendar where their attributes match all of the arguments in the call.
• void removeEvent(Event event) – Remove (all) Event objects in the Calendar that are equals to the event argument. Use the equals method from the Event class to compare the Events.
• void printEvents(int year, int month, int day) – Print every Event in the associated Calendar that matches the date arguments. Print each on a separate line, using the toString method from the Event class.
• void printEvents(Date date) – Same as above.
• Event findEvent(String activity) – Return the (first) Event in the Calendar thathas a matching (equals) activity field. If no match is found, you must return a reference type, so you return null.
• void dump() – Print every Event in the Calendar, as with printEvents.
- 09-06-2010, 07:34 AM #2
I'm not sure I understand the meaning of the post, for two reasons:
1) There is no PDF file attached.
2) I don't see any particular question being asked. What exactly is it that you need help with? Are you hoping someone will just write the code for you? 'Cause if so, you'll want a rent-a-coder website instead.
- 09-06-2010, 07:47 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
I attached the file but for some reason i can't see that. I just want to know how to approach that.
-
Your assignment tells you exactly what you must do. I'd recommend you jump on in, and do it one step at a time. Remember to compile frequently and to fix all compile errors before adding more code. My signature link "so you need to write a program..." can help you too. Please have a look at it. Then if you're still having problems, please come on back and ask your questions and show your code, but remember, the more specific the question, usually the more helpful the answer.
Much luck!
- 09-06-2010, 09:59 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
thank u so much for ur complete answer. That was really useful. I'm writing a Calendar which has 3 classes. For the fist class which is called "date" is it ok to use a constructor like this?:
public Date(int initialYear, int initialMonth, int initialDay) {
if((initialYear<2000) && (initialYear>2100))
{
System.out.println("Error:incorrect date");
System.exit(1);
}
else
{year=initialYear;
}
if((initialMonth<1) && (initialMonth>12))
{ System.out.println("Error:incorrect date");
System.exit(1);
}
else
{ month=initialMonth;
}
if((initialDay<1) && (initialDay>31))
{
System.out.println("Error:incorrect date");
System.exit(1);
}
else {
day=initialDay;
}
}
thanx.
- 09-06-2010, 10:53 PM #6
System.exit() is a bit hard on users. Could you change that to throw an Exception instead?
- 09-06-2010, 10:58 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
How to use Calendar class
By JavaBean in forum Java TipReplies: 1Last Post: 06-26-2008, 03:09 PM -
How to set values with Calendar class ?
By mohiit in forum New To JavaReplies: 3Last Post: 05-14-2008, 04:21 AM -
How to use Calendar class
By Java Tip in forum java.utilReplies: 0Last Post: 04-04-2008, 02:33 PM -
Java Calendar Class
By vasu18 in forum New To JavaReplies: 1Last Post: 12-22-2007, 02:51 AM -
Java Calendar Class
By vasu18 in forum New To JavaReplies: 0Last Post: 12-06-2007, 10:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks