Hunter McMillen wrote:I'm glad that it works like that, but there is still a better way of solving this that doesn't require those additional variables. Remove those variables and try moving around where you increment i_Fstlet and decrement i_Laslet.
Hunter
Hunter McMillen wrote:Actually I was mistaken, the way you have your condition set up will work for both odd and even numbered palindromes. congrats.
Hunter
Hunter McMillen wrote:Actually I was mistaken, the way you have your condition set up will work for both odd and even numbered palindromes. congrats.
Hunter
Hunter McMillen wrote:There is a different case you will have to handle in your loop depending on whether the word you are looking at has an odd or even number of letters.
Hunter
Hunter McMillen wrote:
i need to increment both the end the first letter? but will this work for smaller words?
Try it out and let me know what you find.
Hunter
Hunter McMillen wrote:correct, so look at your loop and trace what you are comparing by hand. I'll use the example word "hannah" and do the first letter.
which letter positions do you need to increment/decrement to compare ( a and a)??
which letter positions are you incrementing?
Hunter
Paul Clapham wrote:
Anthony Pena wrote:
Hunter McMillen wrote:hmm, well you aren't incrementing in the correct place. Try this, ignore the program for a bit and explain to me how you would determine whether a word was a palindrome on a piece of paper.
Hunter
you would compare the first and last, the second and second to last the third and third to last...
correct?
No, that isn't correct. You haven't said how or when you stop comparing. And your instructions don't make sense if there are only two letters, for example. You need to be clearer about such things.
Hunter McMillen wrote:hmm, well you aren't incrementing in the correct place. Try this, ignore the program for a bit and explain to me how you would determine whether a word was a palindrome on a piece of paper.
Hunter
Hunter McMillen wrote:you never increment the positions of the letters you are comparing, so the program compares the first and last letter forever.
Hunter
Campbell Ritchie wrote: . . . and have you done anything else with line 12?
Campbell Ritchie wrote:It looks as if the problem is on line 12.
You have made things difficult for yourself by trying to write the whole thing in one go. You ought to do it bit by bit.
Try printing the code base URL and the toString method of the Image to screen; then you can narrow down where the error occurs: is it code base or is it the image?
And the length of your actionPerformed method is a good example of why addActionListener(this) is poor, non-object-oriented programming. Even though there are lots of books which show such code.