logo Practice-It logo

Hyena

Related Links:
Author: Marty Stepp

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

Write a class Hyena that extends the Critter class, along with its movement and eating behavior. All unspecified aspects of Hyena use the default behavior. Write the complete class with any fields, constructors, etc. necessary.

A Hyena object moves in a rectangular pattern looking for food, walking NORTH, then EAST, then SOUTH, then WEST. Each time the Hyena walks an entire rectangle or eats food, it starts the rectangle pattern over again but with a rectangle 1 step wider than before. The general pattern is as follows, if the Hyena doesn't find any food:

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

If the Hyena encounters food at any point during its movement pattern, it eats the food and starts the pattern over, lengthening the rectangular pattern by 1 in the process. For example:

  • N, E, S, W, N, E, E (eats food), N, E, E, E, S, W, W (eats food), N, E, E, E, E, S, W, W, W, W, N, E, E, E, E, E, S (eats food), N, E, E, E, E, E, E, S, W, W, ...
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.