Class Bat

java.lang.Object
  extended by Thing
      extended by Creature
          extended by Bat
All Implemented Interfaces:
Flyer

public class Bat
extends Creature
implements Flyer

Bat is a creature that knows how to fly.


Constructor Summary
Bat(java.lang.String name)
          Create a Bat with a name.
 
Method Summary
 void eat(Thing aThing)
          A Bat eats only Creatures in the same way that any Creature eats.
 void fly()
          When asked to fly, a Bat prints the message '{name} {class} is swooping through the dark.' (the single quotes are not part of the message.)
 void move()
          When asked to move, a Bat flies.
 
Methods inherited from class Creature
whatDidYouEat
 
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

Bat

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

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

eat

public void eat(Thing aThing)
A Bat eats only Creatures in the same way that any Creature eats.
However, Bats will not eat simple things. If a bat eats something that is NOT an instance of Creature (i.e. a bat eats an instance of Thing), then it reports '{name} {class} won't eat a {aThing}.'
(the single quotes are not part of the message, {name} {class} is the bat's string representation, and aThing is the string representation of aThing.) Finally, if aThing is an instance neither of Creature nor Thing. the bat is silent and does not eat the instance.

Overrides:
eat in class Creature
Parameters:
aThing - -- what this is told to eat

move

public void move()
When asked to move, a Bat flies. That is, the instance calls its own fly() method.

Specified by:
move in class Creature

fly

public void fly()
When asked to fly, a Bat prints the message '{name} {class} is swooping through the dark.' (the single quotes are not part of the message.)

Specified by:
fly in interface Flyer