public boolean addEvent(int year, int month, int day, int hour, int minute, int duration, String what);
This will return true if the event was added and false otherwise. Only valid events will be added to the list.

i kind of understand what im suppose to do but i just cant figure out the coding. calenderEvent is being declared in another class. i just need help with these directions turning them into coding

public boolean addEvent(int year, int month, int day, 
        int hour, int minute, int duration, String what){
        
        if(CalenderEvent != addEvent)
        return true;
        else if (CalenderEvent != addEvent)
            return false;

Recommended Answers

All 2 Replies

You can't use == (or !=) to test for equality against Objects. You have to use the .equals() method. And your method is intended to return true if you successfully added the event to the calendar and false if adding the event to the calendar was not successful. Presumably, an event would be added successfully so long as the year, day, month, etc were all valid and provided the event itself was not already in the calendar. Otherwise, it would not be added successfully, and you would need to return false. Also - you made no attempt to actually add the event to the calendar, which is what you should be doing in that addEvent method. Before adding the event to the calendar, you need to check all those things I just mentioned. (Like checking that the year, day, month are valid).

mmkay that clears it up for me just a bit

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.