I am trying to remove an object if its "energy" is less then 10. "Energy" is an instance variable of a Creature object.
This is a method in my World Class that I hope will accomplish this task. getEnergy() is a method defined in the Creature class that simple returns energy.
When I run this, I am told:"cannot find symbol - method get energy()"
So I tried accessing the method this way:
and I am told: non-static method getEnergy() cannot be referenced from a static context.
public void cullHerd()
{
List<Object> creaturesToRemove = new ArrayList<Object>();
creaturesToRemove = getObjects(Creature.class);
for (int i = 0; i < creaturesToRemove.size(); i = i + 1)
{
Actor a = (Actor) creaturesToRemove.get(i);
if (a.getEnergy() < 10)
{
removeObject(a);
}
}
}
if (Creature.getEnergy() < 10)
