*
The moose likes Java in General and the fly likes Java BlueJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Java BlueJ" Watch "Java BlueJ" New topic
Author

Java BlueJ

Eli Andrus
Greenhorn

Joined: Oct 17, 2011
Posts: 20
Hey guys, I was wondering, I am working on something in a project that has to do with appointments. I create an object and make an appointment set for 1 hour at 10 a.m, and then I make another appointment and it is 2 hours which I set for 9 a.m. when I run it, it returns true. This is the code I am working with, and how would I be able to figure this out. (to make it return false)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
I know there is lots of controversy about it, but I am of the school of thought that you ought not to use return twice. Also you should not say if (...) return true; else return false;
You ought to go through all your if blocks with a pencil and see which returns true or false. What are you going to do if your new Appointment starts in a blank and overruns the beginning of an old Appointment? What if you have a two-hour appointment starting at 11pm?
Why are you starting your array at index 0? That would appear to put all your appointments at the beginning of the day regardless.[edit]I was mistaken about that line. Sorry.[/edit]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
You are only testing whether the beginning of the appointment time is null. You have no means of testing whether the new appointment overruns the beginning of the old appointment.

And I hardly thing your question is about BlueJ.
 
GeeCON Prague 2014
 
subject: Java BlueJ