Class Animal

java.lang.Object
  extended by greenfoot.Actor
      extended by Animal

public class Animal
extends greenfoot.Actor

Animal. This is the base class for all animals. In addition to the standard Actor methods, it provides methods to eat other animals and check for the edge of the world.

Version:
2.0
Author:
Michael Kšlling

Constructor Summary
Animal()
           
 
Method Summary
 boolean atWorldEdge()
          Test if we are close to one of the edges of the world.
 boolean canSee(java.lang.Class clss)
          Return true if we can see an object of class 'clss' right where we are.
 void eat(java.lang.Class clss)
          Try to eat an object of class 'clss'.
 
Methods inherited from class greenfoot.Actor
act, addedToWorld, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, move, setImage, setImage, setLocation, setRotation, turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Animal

public Animal()
Method Detail

atWorldEdge

public boolean atWorldEdge()
Test if we are close to one of the edges of the world. Return true is we are.


canSee

public boolean canSee(java.lang.Class clss)
Return true if we can see an object of class 'clss' right where we are. False if there is no such object here.


eat

public void eat(java.lang.Class clss)
Try to eat an object of class 'clss'. This is only successful if there is such an object where we currently are. Otherwise this method does nothing.