edu.colorado.simulations
Class Plant

java.lang.Object
  extended by edu.colorado.simulations.Organism
      extended by edu.colorado.simulations.Plant

public class Plant
extends Organism

A Plant is an Organism with extra methods that allow it to be eaten.

Java Source Code for this class:
http://www.cs.colorado.edu/~main/edu/colorado/simulations/Plant.java

See Also:
Organism

Constructor Summary
Plant(double initSize, double initRate)
          Construct a Plant with a specified size and growth rate.
 
Method Summary
 void nibbledOn(double amount)
          Have this Plant lose some of its size by being eaten.
 
Methods inherited from class edu.colorado.simulations.Organism
alterSize, expire, getRate, getSize, isAlive, setRate, simulateWeek
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plant

public Plant(double initSize,
             double initRate)
Construct a Plant with a specified size and growth rate.

Parameters:
initSize - the initial size of this Plant, in ounces
initRate - the initial growth rate of this Plant, in ounces
Precondition:
initSize >= 0. Also, if initSize is zero, then initRate must also be zero.
Postcondition:
This Plant has been initialized. The value returned from getSize() is now initSize, and the value returned from getRate() is now initRate.
Throws:
java.lang.IllegalArgumentException - Indicates that initSize or initRate violates the precondition.
Method Detail

nibbledOn

public void nibbledOn(double amount)
Have this Plant lose some of its size by being eaten.

Parameters:
amount - The amount of this Plant that is eaten (in ounces).
Precondition:
0 <= amount <= getSize().
Postcondition:
The size of this Plant has been decreased by amount. If this reduces the size to zero, then expire is activated.