Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java BlueJ

 
Eli Andrus
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic