Question: Write a Java program for the following: The program needs to run until all animals are full . You must create a very simple farm

Write a Java program for the following:

Write a Java program for the following: The program needs to run

until all animals are full. You must create a very simple farm

simulation The simulation will run in a loop and call a method

that indicates the passage of time. More detail on creating the simulation

The program needs to run until all animals are full.

You must create a very simple farm simulation The simulation will run in a loop and call a method that indicates the passage of time. More detail on creating the simulation will be provided in part three. YOU MUST USE A GENERIC CONTAINER such as ArrayList The Generic it has must be some form of the base class ANIMAL Such as: ArrayList farm-new ArrayList0 1. Create an Animal Class that will be the base class for all your animals: All animals have some level of hunger from 0-24. 2. When an animal is instantiated, it should randomly pick some number of hunger units between 0 and 24. (in the constructor) 3. Since it is a small farm all animals have their own name. 4. All animals must be able to be fed (decrease their hunger units by 5 when they are fed). 5. Animals must increase their hunger as time goes on: create a method that increases their hunger by 1 unit of hunger. 6. In the loop example below tick() is used since the method relates to the virtual other simulators might have much more complex effects. public static void main(String] args) ArrayList farm- new ArrayList); 1> farmnew ArrayList for (Animal animal: farm) animal.tick(); animal.feed(); System.out.println(animal.speak)); System.out.println(animal); You must create a very simple farm simulation The simulation will run in a loop and call a method that indicates the passage of time. More detail on creating the simulation will be provided in part three. YOU MUST USE A GENERIC CONTAINER such as ArrayList The Generic it has must be some form of the base class ANIMAL Such as: ArrayList farm-new ArrayList0 1. Create an Animal Class that will be the base class for all your animals: All animals have some level of hunger from 0-24. 2. When an animal is instantiated, it should randomly pick some number of hunger units between 0 and 24. (in the constructor) 3. Since it is a small farm all animals have their own name. 4. All animals must be able to be fed (decrease their hunger units by 5 when they are fed). 5. Animals must increase their hunger as time goes on: create a method that increases their hunger by 1 unit of hunger. 6. In the loop example below tick() is used since the method relates to the virtual other simulators might have much more complex effects. public static void main(String] args) ArrayList farm- new ArrayList); 1> farmnew ArrayList for (Animal animal: farm) animal.tick(); animal.feed(); System.out.println(animal.speak)); System.out.println(animal)

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!