Lesson 1 Key
Lesson 1 - Getting to know GridWorld
Exercise Key, Lesson 1:
1. It tries to move forward in the direction it is pointed (the angle that the getDirection( ) method would return). The Bug can generally move horizontally, vertically, and diagonally at 45 degree angles. The direction at which a Bug is set is rounded to the nearest horizontal, vertical, or 45 degree angle to determine the actual direction in which it will move.
2. The Bug would be unable to move, if by moving in its prescribed direction, it would encounter a Rock, another Bug, or the edge of the grid.
3. It turns 45 degrees clockwise.
4. A Flower of the same color as the Bug.
5. Only one
6. Yes, the moveTo method will move it.
9. Yes, because it would be possible to see “which way” the Rock is pointed.
10. No. Yes, with its moveTo method
11. It turns 45 degrees clockwise.
12. It destroys the Flower object.
13. The Bug is destroyed and if the rock is moved again, an empty cell is left behind (no Bug juice left behind).
14. 270 or Location.WEST
15. An exception is thrown.
Link to this Page
- Beth Zullo last edited on 25 July 2008 at 9:55 am by 22.214.171.124.transedge.com