Part1-2

Part1-2



1. Test the setDirection method with the following inputs and complete the table, giving the compass direction each input represents.

Answer:

DegressCompass Direction
0North
45Northeast
90East
135Southeast
180South
225Southwest
270West
315Northwest
360North



2. 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?

Answer:

①When using the moveTo method, I can move a bug in any direction and distance as long as the destination is a empty cell in the grid. But the original direction of the bug does not change.

② If I try to move the bug outside the grid, a dialog will show up (throw java.lang.illegalArgumentException) and tell me that the location is invalid. And the bug will stay in its original location.

在这里插入图片描述



3. Change the color of a bug, a flower, and a rock. Which method did you use?

Answer:

Each of these actor has a setColor() method, which can change the color itself.

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述



4. Move a rock on top of a bug and then move the rock again. What happened to the bug?

Answer:

①After a few attempts, I found that if I moved a rock above a bug, it would disappear from the grid.

② When the rock is moved to another cell, the previous cell remains empty, as if the bug has been removed from the grid.



GUI Summary

Mouse ActionKeyboard ShortcutResult
Click on an empty locationSelect empty location with cursor keys and press the Enter keyShows the constructor menu
Click on an occupied locationSelect occupied location with cursor keys and press the Enter keyShows the method menu
Select the Location -> Delete menu itemPress the Delete keyRemoves the occupant in the currently selected location from the grid
Click on the Step buttonAfter clicking step once, press the space keyCalls act on each actor
Click on the Run buttonNoneStarts run mode (in run mode, the action of the Step button is carried out repeatedly)
Click on the Stop buttonAfter clicking run once, press the space keyStops run mode
Adjust the Slow/Fast sliderNoneChanges speed of run mode
Select the Location -> Zoom in/Zoom out menu itemPress the Ctrl+PgUp / Ctrl+PgDn keysZooms grid display in or out
Adjust the scroll bars next to gridMove the location with the cursor keysScrolls to other parts of the grid (if the grid is too large to fit inside the window)
Select the World -> Set grid menu itemPress the Alt+W key,and Enter key. Then use Up or Down to chose World -> Set grid menu item and press Enter keyChanges between bounded and unbounded grids
Select the World -> Quit menu itemPress the Ctrl+Q keys QQuits GridWorld

What’s more, if you want to Select the Location menu item, please press the Ctrl+L keys.
If you want to Select the Help menu item, please press the Ctrl+H keys.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值