Question: I need help with my Java class homework to create the code needed for this program This is for my Java programming class: Write a

I need help with my Java class homework to create the code needed for this program

This is for my Java programming class:

Write a simulation of predators and prey as follows:

The world is modeled as a 20x20 array. Each slot can contain at most one animal.

Rabbits like hoping around the world, and work as follows:

Each time step, the rabbit will move in a direction randomly. If the move takes the rabbit off the field (such as moving left from column 0), or if the destination cell is already occupied, the rabbit stays in the current square.

Every third timestep that the rabbit is still alive, it breeds by creating a new rabbit in an adjacent square (if all adjacent squares are occupied, or off of the map, the rabbit can not breed and must wait another three time steps).

Foxes enjoy eating rabbits and work as follows:

Each time step, the fox will move in a direction randomly. If the move takes the fox off of the world, or on top of another fox, the fox stays in the same square. If the move takes the fox on top of a rabbit, the fox eats the rabbit.

If the fox goes three moves without eating any rabbits, the fox dies of starvation.

If the fox is still alive, it will breed every 8 moves.

Write routines to display the state of the field, and simulate the behavior of the foxes and rabbits (which should be derived classes from the base class Animal). Initialize the simulation with 5 foxes and 100 rabbits.

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!