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)
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.I was mistaken about that line. Sorry.[/edit]
Joined: Oct 13, 2005
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.