The only part of this that isn't working the way I want is the '==null' part. If I try to rent a movie that ISN'T in my collection, I want the boolean value to return as false and I want a message displayed that says the movie isn't in the collecion.
With the break statements: The null method doesn't ever get used, if I try to return a movie that doesn't exist I get the false return plus the message "Selected movie is not currently rented out, cannot return."
Without the break statments: If I try to return a movie that isn't in the collection I get the false return plus both messages, "Selected movie is not currently rented out, cannot return." and "Selected movie is not in the collection."
How can I break this up so they both get the return of false, but each one has a differnt message?
Firstly, the comparison with null should be the first of the three, because if it is true (i.e. the object is null), either of the two other statements would bomb out with a NullPointerException. So currently, that comparison is never going to execute.
Secondly, with the code as shown you can never get both message for the same movie, because only one of the three branches ever gets executed. You can only get them in succession for two different movie titles if the first branch is taken (because that is the only one that does not terminate the iteration).
It is not totally clear to me what the code is supposed to do, so I can't comment on the iteration logic. E.g. how do you know which movie is to be returned given that the 'title' parameter is not used? [ August 07, 2005: Message edited by: Ulf Dittmer ]
Also notice that the method as written *always* will return false (even if you drop the break statements).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus