1 | Which statement(s) in the canMove() method ensures that a bug does not try to move out of its grid? | If (!gr.isValid(next)) return false; |
2 | Which statement(s) in the canMove()method determines that a bug will not walk into a rock? | return (neighbor == null) || (neighbor instanceOf Flower); |
3 | Which methods of the Grid interface are invoked by the canMove() method and why? | Not sure. |
4 | Which method of the Location class is invoked by the canMove() method and why? | getAdjacentLocation() its checks if the other blocks in the grid are valid so the object can move into the empty space. |
5 | Which methods inherited from the Actor class are invoked in the canMove()method? | getDirection getLocation get Grid |
6 | What happens in the move() method when the location immediately in front of the bug is out of the grid? | The bug is automatically deleted from the grid. |
7 | Is the variable loc needed in the move()method, or could it be avoided by callinggetLocation() multiple times? | Getlocation method |
8 | Why do you think the flowers that are dropped by a bug have the same color as the bug? | Because they inherit the colour class from the bug |
9 | When a bug removes itself from the grid, will it place a flower into its previous location? | Yes it will |
10 | Which statement(s) in the move() method places the flower into the grid at the bug’s previous location? | Flower flower = new Flower(getColor()); |
11 | If a bug needs to turn 180 degrees, how many times should it call the turn()method? | four |
Sunday, 27 February 2011
Grid World Page 25 and 26
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment