A RightTurningBug behaves like a Bug (
declaration Bug ), except that when it turns, it turns 90 degrees to the right. The declaration for the RightTurningBug class is as follows.
public class RightTurningBug extends Bug
{
public void turn()
{
/* missing implementation */
}
}
Consider the following suggested replacements for /* missing implementation */.
I.
int desiredDirection = (getDirection ( ) + Location.RIGHT) % Location.FULL_CIRCLE;
while (getDirection() != desiredDirection)
{
super.turn();
}
II.
super.turn();
super.turn();
III.
setDirection(getDirection() + Location.RIGHT);
Which of the replacements will produce the desired behavior?
(A) I only
(B) II only
(C) I and II only
(D) I and III only
(E) I, II, and III