|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.simulations.Organism
edu.colorado.simulations.Animal
edu.colorado.simulations.Herbivore
public class Herbivore
A Herbivore is an Animal with extra methods that
allow it to eat Plant objects.
Animal,
Plant| Constructor Summary | |
|---|---|
Herbivore(double initSize,
double initRate,
double initNeed)
Construct an Herbivore with a specified size, growth rate, and
weekly eating need. |
|
| Method Summary | |
|---|---|
void |
nibble(Plant meal)
Have this Herbivore eat part of a Plant. |
| Methods inherited from class edu.colorado.simulations.Animal |
|---|
eat, getNeed, setNeed, simulateWeek, stillNeed |
| Methods inherited from class edu.colorado.simulations.Organism |
|---|
alterSize, expire, getRate, getSize, isAlive, setRate |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Herbivore(double initSize,
double initRate,
double initNeed)
Herbivore with a specified size, growth rate, and
weekly eating need.
initSize - the initial size of this Herbivore, in ouncesinitRate - the initial growth rate of this Herbivore, in ouncesinitNeed - the initial weekly eating requirement of this Animal, in
ounces per week
initSize >= 0 and initNeed >= 0.
Also, if initSize is zero, then
initRate must also be zero.
Herbivore has been initialized. The value returned from
getSize() is now initSize, the value
returned from getRate() is now initRate, and
this Herbivore must eat at least initNeed ounces
of food each week to survive.
java.lang.IllegalArgumentException - Indicates that initSize, initRate, or
initNeed violates the precondition.| Method Detail |
|---|
public void nibble(Plant meal)
Herbivore eat part of a Plant.
meal - the Plant that will be partly eaten
Plant has been eaten by this Herbivore,
by activating both eat(amount) and
meal.nibbledOn(amount). The amount is usually
half of the Plant, but it will not be more than 10% of
this Herbivore’s weekly need nor more than the amount that
this Herbivore still needs to eat to survive this week.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||