|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.simulations.Organism
public class Organism
An Organism object simulates a growing organism such as a
plant or animal.
Animal,
Plant| Constructor Summary | |
|---|---|
Organism(double initSize,
double initRate)
Construct an Organism with a specified size and growth rate. |
|
| Method Summary | |
|---|---|
void |
alterSize(double amount)
Change the current size of this Organism by a given amount. |
void |
expire()
Set this Organism’s size and growth rate to zero. |
double |
getRate()
Get the growth rate of this Organism. |
double |
getSize()
Get the current size of this Organism. |
boolean |
isAlive()
Determine whether this Organism is currently alive. |
void |
setRate(double newRate)
Set the current growth rate of this Organism. |
void |
simulateWeek()
Simulate the passage of one week in the life of this Organism. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Organism(double initSize,
double initRate)
Organism with a specified size and growth rate.
initSize - the initial size of this Organism, in ouncesinitRate - the initial growth rate of this Organism, in ounces
initSize >= 0. Also, if initSize is zero, then
initRate must also be zero.
Organism has been initialized. The value returned from
getSize() is now initSize, and the value
returned from getRate() is now initRate.
java.lang.IllegalArgumentException - Indicates that initSize or initRate violates
the precondition.| Method Detail |
|---|
public void alterSize(double amount)
Organism by a given amount.
amount - the amount to increase or decrease the size of this
Organism (in ounces)
Organism. If this new size is less than or equal to zero,
then expire is also activated.public void expire()
Organism’s size and growth rate to zero.
- - none
Organism have been set
to zero.public double getRate()
Organism.
- - none
Organism (in ounces per week)public double getSize()
Organism.
- - none
Organism (in ounces)public boolean isAlive()
Organism is currently alive.
- - none
Organism’s current current size is greater than
zero, then the return value is true; otherwise the return
value is false.public void setRate(double newRate)
Organism.
newRate - the new growth rate for this Organism (in ounces per week)
newRate must also be
zero.
Organism has been set to
newRate.
java.lang.IllegalArgumentException - Indicates that the size is currently zero, but the newRate
is nonzero.public void simulateWeek()
Organism.
- - none
Organism has been changed by its current
growth rate. If the new size is less than or equal to zero, then
expire is activated to set both size and growth rate to
zero.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||