Question: Write the comments on every line of the following code. public ZBug(int length) { steps = 0; segment = 1; segmentLength = length; setDirection(Location.EAST); }

Write the comments on every line of the following code.
public ZBug(int length)
{
steps = 0;
segment = 1;
segmentLength = length;
setDirection(Location.EAST);
}
/**
* Moves to the next location of the square.
*/
public void act()
{
if (segment
{
if (canMove());
{
move();
steps++;
}
}
else if (segment==1)
{
setDirection(Location.SOUTHWEST);
steps = 0;
segment++;
}
else if (segment==2)
{
setDirection(Location.EAST);
steps=0;
segment++;
}
}
}
GridWorld World Location Help Click on a grid location to construct or manipulate an actor. Step Run Stop Slow Fast
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
