need help with some coding

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2009
Posts: 5
Reputation: bkafroboy69 is an unknown quantity at this point 
Solved Threads: 0
bkafroboy69 bkafroboy69 is offline Offline
Newbie Poster

need help with some coding

 
0
  #1
Nov 5th, 2009
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

  1. public boolean addEvent(int year, int month, int day,
  2. int hour, int minute, int duration, String what){
  3.  
  4. if(CalenderEvent != addEvent)
  5. return true;
  6. else if (CalenderEvent != addEvent)
  7. return false;
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,654
Reputation: BestJewSinceJC is a splendid one to behold BestJewSinceJC is a splendid one to behold BestJewSinceJC is a splendid one to behold BestJewSinceJC is a splendid one to behold BestJewSinceJC is a splendid one to behold BestJewSinceJC is a splendid one to behold 
Solved Threads: 206
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso
 
0
  #2
Nov 5th, 2009
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).
Last edited by BestJewSinceJC; Nov 5th, 2009 at 7:47 pm.
Out.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 5
Reputation: bkafroboy69 is an unknown quantity at this point 
Solved Threads: 0
bkafroboy69 bkafroboy69 is offline Offline
Newbie Poster
 
0
  #3
Nov 5th, 2009
mmkay that clears it up for me just a bit
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 156 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC