/* Critter.java */ /* DO NOT CHANGE THIS FILE. */ /* YOUR SUBMISSION MUST WORK CORRECTLY WITH _OUR_ COPY OF THIS FILE. */ import java.io.*; /** * Each Critter object represents a shark or fish and its position in the * ocean. Critters are your way of telling the animation routines where to * draw sharks and fish. * * Do not use Critters in your internal ocean representations in the * DenseOcean and SparseOcean classes! Critters exist solely as a way of * allowing your Ocean.nextCritter() methods to return three integers at * once. * * @author Jonathan Shewchuk */ public class Critter { public final static int SHARK = 1; public final static int FISH = 2; public int species; // SHARK or FISH public int x; // x-coordinate of the critter in the ocean public int y; // y-coordinate of the critter in the ocean /** * Constructor for a Critter of specified species at (x, y). * @param species is SHARK or FISH. * @param x is the x-coordinate of the Critter's position in the ocean. * @param y is the y-coordinate of the Critter's position in the ocean. * @return the newly constructed Critter. */ public Critter(int species, int x, int y) { if ((species != SHARK) && (species != FISH)) { System.out.println("Error: Illegal critter type!"); System.exit(1); } this.species = species; this.x = x; this.y = y; } }