logo Practice-It logo


Related Links:
Author: Marty Stepp (on 2010/12/28)

("Critter" classes come from the University of Washington's CSE 142 Critters homework assignment. See the assignment spec for more information.)

Write a critter class Daisy along with its movement and eating behavior. All unspecified aspects of Daisy use the default behavior. Write the complete class with any fields, constructors, etc. necessary to implement the behavior.

A Daisy object generally moves in an upward zigzag pattern, going east four times, north once, west four times, north once, and repeating:

  • E, E, E, E, N, W, W, W, W, N, E, E, E, E, N, W, W, W, W, N, ...

When a Daisy finds food, she eats it. The eating of food causes the Daisy to slow down for a while, so that each of the next 3 regular moves are preceded by a move to the center. For example:

  • E, E, E, E, N, W, W (eats), C, W, C, W, C, N, E, E, E, E, N (eats), C, W, C, W, C, W, W, N, ...

If a Daisy eats food again before she has finished making her "slowed down" 3 moves, the slow-down counter goes back up to 3 again:

  • E, E, E, E, N, W, W (eats), C, W, C, W (eats), C, N, C, E, C, E, E, E, N, W, W, W, W, N, ...
Type your solution here:

This is an inheritance problem. Write a Java class using inheritance. (You do not need to write any import statements.)

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.