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;

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

Edited 7 Years Ago by BestJewSinceJC: n/a

This article has been dead for over six months. Start a new discussion instead.