- Test the setDirection method with the following inputs and complete the table, giving the compass direction each input represents.
Degrees | Compass Direction |
---|---|
0 | North |
45 | North-East |
90 | East |
135 | South-East |
180 | South |
225 | South-West |
270 | West |
315 | North-West |
360 | North |
- Move a bug to a different location using the moveTo method. In which directions can you move it? How far can you move it? What happens if you try to move the bug outside the grid?
调用moveTo
方法可以将 bug 向任意方向移动。
若尝试将 bug 移出 grid ,会抛出 “位置非法” 错误。
- Change the color of a bug, a flower, and a rock. Which method did you use?
调用setColor
方法改变 bug 或 flower 或 rock 对象的颜色。
- Move a rock on top of a bug and then move the rock again. What happened to the bug?
bug 被 “砸死” 了。当 rock 对象调用moveTo
方法移动到 bug 所在的 grid 时,bug 对象被销毁。