Class FieldStats

java.lang.Object
  extended by FieldStats

public class FieldStats
extends java.lang.Object

This class collects and provides some statistical data on the state of a field. It is flexible: it will create and maintain a counter for any class of object that is found within the field.

Version:
2011.07.31
Author:
David J. Barnes and Michael Kölling

Constructor Summary
FieldStats()
          Construct a FieldStats object.
 
Method Summary
 void countFinished()
          Indicate that an animal count has been completed.
 int getPopulationCount(Field field, java.lang.Class key)
          Get the number of individuals in the population of a given class.
 java.lang.String getPopulationDetails(Field field)
          Get details of what is in the field.
 void incrementCount(java.lang.Class animalClass)
          Increment the count for one class of animal.
 boolean isViable(Field field)
          Determine whether the simulation is still viable.
 void reset()
          Invalidate the current set of statistics; reset all counts to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldStats

public FieldStats()
Construct a FieldStats object.

Method Detail

countFinished

public void countFinished()
Indicate that an animal count has been completed.


getPopulationCount

public int getPopulationCount(Field field,
                              java.lang.Class key)
Get the number of individuals in the population of a given class.

Returns:
An int with the number for this class.

getPopulationDetails

public java.lang.String getPopulationDetails(Field field)
Get details of what is in the field.

Returns:
A string describing what is in the field.

incrementCount

public void incrementCount(java.lang.Class animalClass)
Increment the count for one class of animal.

Parameters:
animalClass - The class of animal to increment.

isViable

public boolean isViable(Field field)
Determine whether the simulation is still viable. I.e., should it continue to run.

Returns:
true If there is more than one species alive.

reset

public void reset()
Invalidate the current set of statistics; reset all counts to zero.