|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs2110.assignment5.Naturalist
public abstract class Naturalist
Abstract naturalist class. To implement a naturalist AI, extend this class and implement the run method.
Field Summary | |
---|---|
static int |
MAX_ANIMAL_CAPACITY
Maximum number of animals that can be carried at a time |
Constructor Summary | |
---|---|
Naturalist()
Default constructor for the naturalist. |
Method Summary | |
---|---|
void |
collect(java.lang.String name)
Collect an animal from the current location. |
void |
dropAll()
Drop all animals currently being carried. |
Node[] |
getExits()
Return an array of Nodes that the naturalist can move to from the current location. |
java.util.Collection<java.lang.String> |
getInventory()
Return a the names of animals being carried by the naturalist |
Node |
getLocation()
Return the current graph node occupied by this thing |
int |
getNodeCount()
The number of nodes in this map. |
java.util.Random |
getRandom()
Returns a random number generator that has been initialized with the game world's default seed. |
java.util.Collection<java.lang.String> |
listAnimalsPresent()
List the animals present at the current location. |
void |
moveTo(Node destination)
Move to an adjacent node. |
abstract void |
run()
Called by the simulator to run the naturalist program. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MAX_ANIMAL_CAPACITY
Constructor Detail |
---|
public Naturalist()
Method Detail |
---|
public abstract void run()
run
in interface java.lang.Runnable
public Node getLocation()
public java.util.Random getRandom()
public Node[] getExits()
public void moveTo(Node destination) throws IllegalMoveException
destination
- An adjacent node
IllegalMoveException
- Thrown if location is not adjacent, or is blocked by water or trees.public java.util.Collection<java.lang.String> listAnimalsPresent()
public void collect(java.lang.String name) throws CapacityExceededException, SpecimenNotFoundException
name
-
CapacityExceededException
- Thrown if already carrying the maximum number of animals, as given by getCapacity().
SpecimenNotFoundException
- Thrown if the named animal is not present.public void dropAll()
public final int getNodeCount()
public final java.util.Collection<java.lang.String> getInventory()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |