Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program to simulate an ecosystem containing two types of creatures, bears and fish . The ecosystem consists of a river, which is

Write a Java program to simulate an ecosystem containing two types of creatures, bears and fish . The ecosystem consists of a river, which is modeled as a relatively large array (i.e. 500 cells). Each cell of the array should contain an Animal object, which can be a bear, a fish, or null . Initialize the array to randomly contain these three types. In each time step, based on a random process, each bear/fish either attempts to move into an adjacent array cell or stay where it is. If two animals of the same type are about to collide in the same cell, then they stay where they are, but they create a new instance of that type of animal, which is placed in an empty (i.e. previously null ) cell in the array. If a bear and a fish collide, then the fish dies (i.e., it disappears). Provide summary information on the array after each time step (time step number and how many bears, fish, and null ). Run the simulation until the ecosystem contains all bears.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions