One use for stepping through code line-by-line is to see in which order the lines get executed. But a much more powerful use is to see the value of local variables and how they change as a result of each line or small section of code. This is the purpose of the Variables pane.
If you have followed the tutorial so far, your screen should resemble this image.
Click on the Variables pane to inspect the parameters and local variables available to this method.
Notice the Variables pane. It is currently in the vertical view. We would like to see the horizontal view instead.
Select
from the drop down menu view options menu to change it to horizontal view.
Next, confirm that the value of the quantity parameter is 3. It is, so we can continue checking the execution of this method.
Click moveFish()
method.
After the first line has been executed, there is a new local variable named i
in the Variable pane.
The entry displays the following for each variable:
quantity
3
Use the addFish()
method. Hint: Count how many times the tank.addFish()
line is executed.
Fix the bug.
When you have fixed the bug, add the following to document your fix.
/************ BUG FIX *************** Programmer(s): Java Jane and Compiler Joe fixed off-by-one error. The iteration should start at 0 and stop at less than quantity. or start at 1 and stop at less than or equal to quantity. ************************************/Provide me with a screenshot of your environment now!