Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I have attempted to code checkers for a school project, but I am unable to code a method for multiple jumps. In my current version, I have attempted to find the possible moves in a one piece radius, add those moves to an ArrayList known as mainList, and use recursion to find all possible moves. Afterward, for each possible final destination piece, the program adds the pieces that need to be reset to "NO" to an ArrayList known as sublist, which is one of the attributes of each piece. However, my jumps do not work.
I have attempted to debug why my program is not removing the correct pieces, and in the image with a trial run posted below, the underlined "RP" with coordinates of (4,3) is not reset, and instead, the program thinks that the piece with coordinates of (3,2) should be reset. Apparently, the program is trying to reset the final destination piece rather than the middle piece. What am I missing that is causing it to do this?
Note: Some of the code has been removed to fit character count.
Debugging a class with variable names like x1, y2, etc. is very difficult for the author and nearly impossible for anyone else! If you're using an IDE, use its Rename function and slowly name variable something that is describes their function. x5 might be renamed pieceColorPrompt, for instance.
I know this doesn't solve your problem directly, but you will find that this process makes debugging much easier.
Some other tips:
Don't write if (something == true), just write if (something)
Class names should begin with an uppercase letter
Don't call a method recursively when you don't need recursion (example: line 52)
All things are lawful, but not all things are profitable.
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Free, earth friendly heat - from the CodeRanch trailboss