Jumper class

posted by: Ms. Martin 21 March 2010 No Comment

You will complete the Jumper class as detailed in the GridWorld case study part 3 document.  I’ve rewritten some of the instructions here — follow these!!

Requirements

You will create a class called Jumper. 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.

Before you get going, you need to figure out how you will address the following situations:

  1. 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?
  2. What will a jumper do if the location two cells in front of the jumper is out of the grid?
  3. What will a jumper do if it is facing an edge of the grid?
  4. 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?
  5. What will a jumper do if it encounters another jumper in its path?
  6. Are there any other tests the jumper needs to make?

Design

Several design decisions need to be considered:

  1. Which class should Jumper extend?
  2. Is there an existing class that is similar to the Jumper class?
  3. Should there be a constructor? If yes, what parameters should be specified for the constructor?
  4. Which methods should be overridden?
  5. What methods, if any, should be added?
  6. What is the plan for testing the class?

Code

Implement the Jumper and JumperRunner classes.

Test

Carry out the test plan to verify that the Jumper class meets the requirements.  This will involve putting an instance of your Jumper class into all the situations outlined in the requirements as special cases.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
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>