Question: i hvae a CritterMain class in java and need to implement the following Write a class Hyena that extends the Critter class, along with its

i hvae a CritterMain class in java and need to implement the following

Write a class Hyena that extends the Critter class, along with its movement behavior. All unspecified aspects of Hyena use the default behavior.

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, it starts the rectangle pattern over again but with a rectangle 1 step wider than before. The general pattern is as follows:

  • 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, ...

Solve this program in jGRASP using the CritterMain simulator.

Modify your Hyena class from the previous problem to add eating behavior. 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, ...

Solve this program in jGRASP with CritterMain, then test it using the Practice-it link above.

Write a class Butterfly that extends the Critter class, along with its movement behavior. All unspecified aspects of Butterfly use the default behavior.

A Butterfly should be yellow in color. Its toString should alternate between being an x character and a - character each move.

A Butterfly flies upward in the following pattern: N, W, N, E, repeat.

Solve this program in jGRASP using the CritterMain simulator.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!