Results 1 to 7 of 7
  1. #1
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default 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.

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    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.

  3. #3
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default

    I attached the file but for some reason i can't see that. I just want to know how to approach that.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by hamed View Post
    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!

  5. #5
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default

    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.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    System.exit() is a bit hard on users. Could you change that to throw an Exception instead?

  7. #7
    hamed is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

Similar Threads

  1. How to use Calendar class
    By JavaBean in forum Java Tip
    Replies: 1
    Last Post: 06-26-2008, 04:09 PM
  2. How to set values with Calendar class ?
    By mohiit in forum New To Java
    Replies: 3
    Last Post: 05-14-2008, 05:21 AM
  3. How to use Calendar class
    By Java Tip in forum java.util
    Replies: 0
    Last Post: 04-04-2008, 03:33 PM
  4. Java Calendar Class
    By vasu18 in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 03:51 AM
  5. Java Calendar Class
    By vasu18 in forum New To Java
    Replies: 0
    Last Post: 12-06-2007, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •