170k views
4 votes
What does this method do?

public void mystery()
{
if( !facingWest() )
turnLeft();
if( !facingWest() )
turnLeft();
if( !facingWest() )
turnLeft();
}

A) Face North
B) Face South
C) Face West
D) Face East

User HexaJer
by
7.8k points

1 Answer

1 vote

Final answer:

This method makes the object face West.

Step-by-step explanation:

This method will make the object face West.

The code checks if the object is not already facing west using the !facingWest() condition. If it is not facing west, the turnLeft() method is called three times in a row to make the object face west.

Therefore, the correct answer is Face West (C).

User Simbarashe
by
8.0k points