Question

On the AP Quick Reference Code, it states "public setDirection(int newDirection) sets the direction of this actor to the angle between 0 and 359 degrees that is equivalent to newDirection"

However, in one of the released exam multiple choice questions, it states that you can set the direction by calling setDirection(getDirection + RIGHT);, however, what if the angle becomes greater or equal to 360 degrees? an example being 390 degrees.

Will this generate a run-time error, or will it just %360 and get the correct reference angle?

Was it helpful?

Solution

I have figured out the answer to my question. Upon compiling the GridWorld Case Study, I can confirm that any integer value (so long as it is a valid integer) can work in the setDirection(new Location); method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top