14 Replies
⌛
This post has been reserved for your question.
Hey @arch__user! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

can anyone clear my doubt ?
What is the issue with it?
For example lets say user guess is 3 and we have an array where startup location is placed at [2,3,4] the first time` the userguess (3) is not equals to 2 and hence the outer else block will be executed which will return miss ? Even though 3 is present in the second element of the array ?
at first iteration when 3 != 2 return miss will be executed which is wrong
because 3 will be equals to 3 in the seccond iteration
Isn't the algo wrong ?
yeah I think that part should be outside of the REPEAT (and doesn't need an ELSE)

setlocation cells is the setter method btw
shouldn't it be like this ?

Isn't that what I just said?
after the repeat
yes. Kinda hard for me to believe there are mistakes in the head first java book
so weird
I haven't read it
maybe you have an old version of it?
I have the latest one 3rd edition
Actually this was the extract I was reading from the book. I made it shorter so that you don't have to read to much :-




💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.