WatorWorld
Class Shark

java.lang.Object
  extended by WatorWorld.Actor
      extended by WatorWorld.Shark

public class Shark
extends Actor

A class to model a Shark in the Wator simulation.


Constructor Summary
Shark()
          Create a new shark.
 
Method Summary
 void act()
          Check if starve then if not, act to move and breed if time.
static int getBreedTime()
           
 char getChar()
          Return the character for Sharks.
static int getNumSharks()
          Returns the current number of sharks.
static Color getStandardSharkColor()
           
static int getStarveTime()
           
static void resetNumSharks()
          Reset number of sharks to 0.
static void setBreedTime(int newBreedTime)
          Change the base number of turns before sharks can breed
static void setStarveTime(int newStarveTime)
          Change the base number of turns a shark must eat within or starve
 
Methods inherited from class WatorWorld.Actor
getColor, getDirection, getGrid, getLocation, isEdible, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, setDirection, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Shark

public Shark()
Create a new shark. Increment number of sharks that exist by 1.

Method Detail

getNumSharks

public static int getNumSharks()
Returns the current number of sharks.

Returns:
the current number of sharks.

resetNumSharks

public static void resetNumSharks()
Reset number of sharks to 0.


setBreedTime

public static void setBreedTime(int newBreedTime)
Change the base number of turns before sharks can breed

Parameters:
newBreedTime - new number of turns. Must be > 0.

setStarveTime

public static void setStarveTime(int newStarveTime)
Change the base number of turns a shark must eat within or starve

Parameters:
newStarveTime - new number of turns. Must be > 0

getStarveTime

public static int getStarveTime()
Returns:
The standard starve time for sharks.

getBreedTime

public static int getBreedTime()
Returns:
The standard breed time for sharks.

getStandardSharkColor

public static Color getStandardSharkColor()
Returns:
The standard color for sharks.

act

public void act()
Check if starve then if not, act to move and breed if time. Sharks act by first checking if they starve. Then they check if they can move. If they can they move to a random location. Then they check to see if it is time to breed. If so then they create an offspring in an open location if one exists. (Could be open due to eating or from moving.)

Overrides:
act in class Actor

getChar

public char getChar()
Return the character for Sharks.

Overrides:
getChar in class Actor
Returns:
the character representation of this SeaCreature