aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 36563
    
  16
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: 36563
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java BlueJ
 
Similar Threads
Help with printing appointments
isOverlap method problems
How to form a new string out of several old strings excluding some??.......
Hibernate - Deleting a parent and it's children
boolean remove(Appointment appt)