Class Creature

java.lang.Object
  extended by Thing
      extended by Creature
Direct Known Subclasses:
Ant, Bat, Fly, Tiger

public abstract class Creature
extends Thing

A Creature is a Thing that has specific, 'lively' behaviors.

Since:
2007

Constructor Summary
Creature(java.lang.String name)
          Create a Creature with a name.
 
Method Summary
 void eat(Thing aThing)
          Creatures may be asked to eat various Things.
abstract  void move()
          Tell the Creature to move.
 void whatDidYouEat()
          Make the Creature tell what is in its stomach.
 
Methods inherited from class Thing
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Creature

public Creature(java.lang.String name)
Create a Creature with a name.

Parameters:
name - -- the given name of this Creature
Method Detail

eat

public void eat(Thing aThing)
Creatures may be asked to eat various Things. By default, creatures eat whatever they are told AND print a message stating '{this object} has just eaten a {a Thing}.' substituting the concrete details for the part enclosed inside of {}. (the single quotes are not part of the message.)
A creature only remembers the last thing it ate.

Parameters:
aThing - -- what this is told to eat

move

public abstract void move()
Tell the Creature to move. Each creature will print a message stating the way it most commonly moves.


whatDidYouEat

public void whatDidYouEat()
Make the Creature tell what is in its stomach. If there is nothing in its stomach, whatDidYouEat() prints '{name} {class} has had nothing to eat!' If it has something in its stomach, whatDidYouEat() prints '{creature name} {class name} has eaten a {content of stomach}!'
NOTE: The pattern {word} in the text above indicates what attribute value belongs in the output text.