Jumper

posted by: Ms. Martin 2 March 2011 No Comment

You will complete the Jumper class as detailed in the GridWorld case study part 3 document.  This actor can move forward two cells in each move. It “jumps” over rocks and flowers. It does not leave anything behind it when it jumps.

NOTE: a Jumper can’t use the same canMove and move methods as a Bug.  That implies it is a sibling of a Bug.

I would like for you to use the specifications below.  When you get checked off, you will need to efficiently show that you’ve addressed each case.  That means you need to have a clear testing plan in mind.

Specifications

a. What will a jumper do if the location in front of it is empty, but the location two cells in front contains a flower or a rock?
Move one cell only.
b. What will a jumper do if the location two cells in front of the jumper is out of the grid?
Move one cell only.
c. What will a jumper do if it is facing an edge of the grid?
Turn like a Bug.
d. What will a jumper do if another actor (not a flower or a rock) is in the cell that is two cells in front of the jumper?
Remove the other Actor and jump to that location.
e. What will a jumper do if it encounters another jumper in its path?
Jumpers are treated the same as any other Actor.
f. Are there any other tests the jumper needs to make?
If both the cell directly in front of and the cell two spaces in front of the Jumper are both blocked, turn like a Bug.

1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 2.00 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>