Question: Its needs to be in java with Critter.java and Stone.java Problem 2 This assignment will give you practice with defining classes. You are to write

 Its needs to be in java with Critter.java and Stone.java Problem
2 This assignment will give you practice with defining classes. You are
to write a set of classes that define the behavior of certain
animals. You will be given a program that runs a simulation of
Its needs to be in java with Critter.java and Stone.java

Problem 2 This assignment will give you practice with defining classes. You are to write a set of classes that define the behavior of certain animals. You will be given a program that runs a simulation of a world with many animals moving around in it. Different kinds of animals will move in different ways and you are defining those differences. As the simulation runs, animals can "die" by ending up on the same location, in which case the simulator randomly selects one animal to survive the collision. For this assignment you will be given a lot of supporting code that runs the simulation. You are just defining the individual "critters" that wander around this world. On each round of the simulation, each critter is asked which direction it wants to move. Each critter can move north, south, east or west or can stay on the current location by saying that the direction it wants is "center." This program will probably be confusing at first because this is the first time where you are not writing the main method. Your code will not be in control. Instead, you are defining a series of objects that become part of a larger system. For example, you might find that you want to have one of your critters make several moves all at once. You won't be able to do that. The only way a critter can move is to wait for the simulator to ask it for a move. The simulator is in control, not your critters. Although this experience can be frustrating, it is a good introduction to the kind of programming we do with objects. A typical Java program involves many different interacting objects that are each a small part of a much larger system. Each of your classes will implement the Critter interface, shown below. // The Critter interface defines the methods necessary for an animal // to participate in the critter simulation. It must return a // character when getChar is called that is used for displaying it on // the screen. The getMove method must return a legal move (one of // the constants NORTH, SOUTH, EAST, WEST, CENTER). See the // Critter Info interface for a description of its methods. public interface Critter { public char getChar(); public int get Move (Critter Info info); public static tinal int NORTH = -1; public static final int SOUTH = 3; public static final int EAST - B; public static final int west - 11: public static final int CENTER = 42: Interfaces are discussed in detail in chapter 9 of the textbook, but to do this assignment you just need to know a few simple rules about interfaces. Your class headers should indicate that they implement this interface, as in: public class Bird implements Critter

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!